本文整理汇总了Java中java.util.EnumMap.size方法的典型用法代码示例。如果您正苦于以下问题:Java EnumMap.size方法的具体用法?Java EnumMap.size怎么用?Java EnumMap.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.EnumMap
的用法示例。
在下文中一共展示了EnumMap.size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toStringMap
import java.util.EnumMap; //导入方法依赖的package包/类
private <T> Map<String, T> toStringMap(EnumMap<? extends Enum<UsageKind>, T> enumMap) {
Map<String, T> map = new HashMap<String, T>(enumMap.size());
for (Map.Entry<? extends Enum<UsageKind>, T> tEntry : enumMap.entrySet()) {
UsageKind usageKind = UsageKind.valueOf(tEntry.getKey().name());
map.put(usageKind.getConfigurationName(), tEntry.getValue());
}
return map;
}
示例2: asImmutable
import java.util.EnumMap; //导入方法依赖的package包/类
static <K extends Enum<K>, V> ImmutableMap<K, V> asImmutable(EnumMap<K, V> map) {
switch (map.size()) {
case 0:
return ImmutableMap.of();
case 1: {
Entry<K, V> entry = Iterables.getOnlyElement(map.entrySet());
return ImmutableMap.of(entry.getKey(), entry.getValue());
}
default:
return new ImmutableEnumMap<K, V>(map);
}
}
示例3: asImmutable
import java.util.EnumMap; //导入方法依赖的package包/类
static <K extends Enum<K>, V> ImmutableMap<K, V> asImmutable(EnumMap<K, V> map) {
switch (map.size()) {
case 0:
return ImmutableMap.of();
case 1:
Entry<K, V> entry = Iterables.getOnlyElement(map.entrySet());
return ImmutableMap.of(entry.getKey(), entry.getValue());
default:
return new ImmutableEnumMap<K, V>(map);
}
}
示例4: determineAttributeNature
import java.util.EnumMap; //导入方法依赖的package包/类
/**
* Given the annotations defined on a persistent attribute this methods determines the attribute type.
*
* @param annotations the annotations defined on the persistent attribute
*
* @return an instance of the {@code AttributeType} enum
*/
private AttributeNature determineAttributeNature(Map<DotName, List<AnnotationInstance>> annotations) {
EnumMap<AttributeNature, AnnotationInstance> discoveredAttributeTypes =
new EnumMap<AttributeNature, AnnotationInstance>( AttributeNature.class );
AnnotationInstance oneToOne = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ONE_TO_ONE );
if ( oneToOne != null ) {
discoveredAttributeTypes.put( AttributeNature.ONE_TO_ONE, oneToOne );
}
AnnotationInstance oneToMany = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ONE_TO_MANY );
if ( oneToMany != null ) {
discoveredAttributeTypes.put( AttributeNature.ONE_TO_MANY, oneToMany );
}
AnnotationInstance manyToOne = JandexHelper.getSingleAnnotation( annotations, JPADotNames.MANY_TO_ONE );
if ( manyToOne != null ) {
discoveredAttributeTypes.put( AttributeNature.MANY_TO_ONE, manyToOne );
}
AnnotationInstance manyToMany = JandexHelper.getSingleAnnotation( annotations, JPADotNames.MANY_TO_MANY );
if ( manyToMany != null ) {
discoveredAttributeTypes.put( AttributeNature.MANY_TO_MANY, manyToMany );
}
AnnotationInstance embedded = JandexHelper.getSingleAnnotation( annotations, JPADotNames.EMBEDDED );
if ( embedded != null ) {
discoveredAttributeTypes.put( AttributeNature.EMBEDDED, embedded );
}
AnnotationInstance embeddedId = JandexHelper.getSingleAnnotation( annotations, JPADotNames.EMBEDDED_ID );
if ( embeddedId != null ) {
discoveredAttributeTypes.put( AttributeNature.EMBEDDED_ID, embeddedId );
}
AnnotationInstance elementCollection = JandexHelper.getSingleAnnotation(
annotations,
JPADotNames.ELEMENT_COLLECTION
);
if ( elementCollection != null ) {
discoveredAttributeTypes.put( AttributeNature.ELEMENT_COLLECTION, elementCollection );
}
if ( discoveredAttributeTypes.size() == 0 ) {
return AttributeNature.BASIC;
}
else if ( discoveredAttributeTypes.size() == 1 ) {
return discoveredAttributeTypes.keySet().iterator().next();
}
else {
throw new AnnotationException( "More than one association type configured for property " + getName() + " of class " + getName() );
}
}