當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。