下面列出了com.google.common.collect.ImmutableSortedMap#copyOfSorted ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void loadMeta(MetaAccumulator meta) {
this.meta = Multimaps.asMap(ImmutableListMultimap.copyOf(meta.getMeta()));
MetaValueSelector metaValueSelector = this.queryOptions.option(MetaValueSelector.KEY)
.orElseGet(() -> this.plugin.getConfiguration().get(ConfigKeys.META_VALUE_SELECTOR));
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Map.Entry<String, List<String>> e : this.meta.entrySet()) {
if (e.getValue().isEmpty()) {
continue;
}
String selected = metaValueSelector.selectValue(e.getKey(), e.getValue());
if (selected == null) {
throw new NullPointerException(metaValueSelector + " returned null");
}
builder.put(e.getKey(), selected);
}
this.flattenedMeta = builder.build();
this.prefixes = ImmutableSortedMap.copyOfSorted(meta.getPrefixes());
this.suffixes = ImmutableSortedMap.copyOfSorted(meta.getSuffixes());
this.weight = meta.getWeight();
this.primaryGroup = meta.getPrimaryGroup();
this.prefixDefinition = meta.getPrefixDefinition();
this.suffixDefinition = meta.getSuffixDefinition();
this.prefix = meta.getPrefix();
this.suffix = meta.getSuffix();
}
/** Defensive copy helper for {@link SortedMap}. */
public static <K, V> ImmutableSortedMap<K, V> nullToEmptyImmutableCopy(SortedMap<K, V> data) {
return data == null ? ImmutableSortedMap.of() : ImmutableSortedMap.copyOfSorted(data);
}
/** Returns the map of DateTime to value that is the "natural" representation of this property. */
public ImmutableSortedMap<DateTime, V> toValueMap() {
return ImmutableSortedMap.copyOfSorted(Maps.transformValues(backingMap, T::getValue));
}
/** Returns a copy of the annotations as a map.
* Dev note: this does not create a copy, unless necessary. See {@link ImmutableSortedMap#copyOfSorted(SortedMap)}*/
public ImmutableSortedMap<String, String> getAnnotations() {
return ImmutableSortedMap.copyOfSorted(this.annotations);
}
private TenorRawOptionData(
SortedMap<Tenor, RawOptionData> data) {
JodaBeanUtils.notNull(data, "data");
this.data = ImmutableSortedMap.copyOfSorted(data);
}
/**
* Returns an immutable copy of the specified sorted {@code map}.
*
* @param map
* the sorted map for which an immutable copy should be created. May not be <code>null</code>.
* @return an immutable copy of the specified sorted map.
*/
@Inline(value="$2.$3copyOfSorted($1)", imported=ImmutableSortedMap.class)
public static <K, V> SortedMap<K, V> immutableCopy(SortedMap<K, ? extends V> map) {
return ImmutableSortedMap.copyOfSorted(map);
}