当前位置: 首页>>代码示例>>Java>>正文


Java EnumMap.size方法代码示例

本文整理汇总了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;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:JvmLocalLibraryMetaDataAdapter.java

示例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);
  }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:13,代码来源:ImmutableEnumMap.java

示例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);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:ImmutableEnumMap.java

示例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() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:60,代码来源:ConfiguredClass.java


注:本文中的java.util.EnumMap.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。