java.util.EnumMap#size ( )源码实例Demo

下面列出了java.util.EnumMap#size ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jboss-logmanager-ext   文件: PropertyValues.java
/**
 * Converts a map into a string that can be parsed by {@link #stringToMap(String)}. The kwy will be the
 * {@linkplain Enum#name() enum name}.
 *
 * @param map the map to convert to a string
 * @param <K> the type of the key
 *
 * @return a string value for that map that can be used for configuration properties
 *
 * @see #escapeKey(StringBuilder, String)
 * @see #escapeValue(StringBuilder, String)
 */
public static <K extends Enum<K>> String mapToString(final EnumMap<K, String> map) {
    if (map == null || map.isEmpty()) {
        return null;
    }
    final StringBuilder sb = new StringBuilder(map.size() * 32);
    final Iterator<Map.Entry<K, String>> iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
        final Map.Entry<K, String> entry = iterator.next();
        sb.append(entry.getKey().name());
        sb.append('=');
        escapeValue(sb, entry.getValue());
        if (iterator.hasNext()) {
            sb.append(',');
        }
    }
    return sb.toString();
}
 
源代码2 项目: ditto   文件: ThingSearchRoute.java
private Route thingSearchParameterOptionalImpl(final ThingSearchParameter[] values,
        final EnumMap<ThingSearchParameter, Optional<String>> accumulator,
        final Function<EnumMap<ThingSearchParameter, Optional<String>>, Route> inner) {

    if (accumulator.size() >= values.length) {
        return inner.apply(accumulator);
    } else {
        final ThingSearchParameter parameter = values[accumulator.size()];
        return parameterOptional(parameter.toString(), parameterValueOptional -> {
            accumulator.put(parameter, parameterValueOptional);
            return thingSearchParameterOptionalImpl(values, accumulator, inner);
        });
    }
}
 
源代码3 项目: codebuff   文件: ImmutableEnumMap.java
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 项目: codebuff   文件: ImmutableEnumMap.java
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);
}
     }
 
源代码5 项目: codebuff   文件: ImmutableEnumMap.java
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);
}
     }
 
源代码6 项目: codebuff   文件: ImmutableEnumMap.java
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);
}
     }
 
源代码7 项目: codebuff   文件: ImmutableEnumMap.java
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);
  }
}
 
源代码8 项目: dss   文件: UniqueServiceFilter.java
@Override
public List<TrustedServiceWrapper> filter(List<TrustedServiceWrapper> trustServices) {
	TrustedServiceWrapper selectedTrustedService = null;

	if (Utils.collectionSize(trustServices) == 1) {
		selectedTrustedService = trustServices.get(0);
	} else if (Utils.isCollectionNotEmpty(trustServices)) {
		LOG.info("More than one selected trust services");

		EnumMap<CertificateQualification, List<String>> qualificationResults = new EnumMap<>(
				CertificateQualification.class);
		for (TrustedServiceWrapper trustService : trustServices) {
			CertificateQualificationCalculation calculator = new CertificateQualificationCalculation(endEntityCert, trustService);
			CertificateQualification certQualification = calculator.getQualification();
			if (!qualificationResults.containsKey(certQualification)) {
				qualificationResults.put(certQualification, trustService.getServiceNames());
			}
		}

		if (qualificationResults.size() > 1) {
			LOG.warn("Unable to select the trust service ! Several possible conclusions {}", qualificationResults);
		} else {
			LOG.info("All trust services conclude with the same result");
			selectedTrustedService = trustServices.get(0);
		}
	}

	if (selectedTrustedService != null) {
		return Collections.singletonList(selectedTrustedService);
	} else {
		return Collections.emptyList();
	}
}
 
源代码9 项目: Carbonado   文件: QueryHints.java
/**
 * Returns a new QueryHints object without the given hint.
 */
public QueryHints without(QueryHint hint) {
    if (hint == null || mMap == null || !mMap.containsKey(hint)) {
        return this;
    }
    EnumMap<QueryHint, Object> map = mMap.clone();
    map.remove(hint);
    if (map.size() == 0) {
        map = null;
    }
    return new QueryHints(map);
}