本文整理汇总了Java中com.google.common.collect.ImmutableSortedSet.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSortedSet.copyOf方法的具体用法?Java ImmutableSortedSet.copyOf怎么用?Java ImmutableSortedSet.copyOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableSortedSet
的用法示例。
在下文中一共展示了ImmutableSortedSet.copyOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializePropertySources
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
protected void initializePropertySources() {
if (environment.getPropertySources().contains(APOLLO_PROPERTY_SOURCE_NAME)) {
//already initialized
return;
}
CompositePropertySource composite = new CompositePropertySource(APOLLO_PROPERTY_SOURCE_NAME);
//sort by order asc
ImmutableSortedSet<Integer> orders = ImmutableSortedSet.copyOf(NAMESPACE_NAMES.keySet());
Iterator<Integer> iterator = orders.iterator();
while (iterator.hasNext()) {
int order = iterator.next();
for (String namespace : NAMESPACE_NAMES.get(order)) {
Config config = ConfigService.getConfig(namespace);
composite.addPropertySource(new ConfigPropertySource(namespace, config));
}
}
environment.getPropertySources().addFirst(composite);
}
示例2: maplist
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Command(
aliases = {"maplist", "maps", "ml"},
desc = "Shows the maps that are currently loaded",
usage = "[page]",
min = 0,
max = 1,
help = "Shows all the maps that are currently loaded including ones that are not in the rotation."
)
@CommandPermissions("pgm.maplist")
public static void maplist(CommandContext args, final CommandSender sender) throws CommandException {
final Set<PGMMap> maps = ImmutableSortedSet.copyOf(new PGMMap.DisplayOrder(), PGM.getMatchManager().getMaps());
new PrettyPaginatedResult<PGMMap>(PGMTranslations.get().t("command.map.mapList.title", sender)) {
@Override public String format(PGMMap map, int index) {
return (index + 1) + ". " + map.getInfo().getShortDescription(sender);
}
}.display(new BukkitWrappedCommandSender(sender), maps, args.getInteger(0, 1) /* page */);
}
示例3: toSortedSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Nonnull
private static <T> SortedSet<? extends T> toSortedSet(@Nonnull Comparator<? super T> elementComparator,
@Nonnull Collection<? extends T> collection) {
if (collection instanceof SortedSet) {
SortedSet<? extends T> sortedSet = (SortedSet<? extends T>)collection;
Comparator<?> comparator = sortedSet.comparator();
if (comparator != null && comparator.equals(elementComparator)) {
return sortedSet;
}
}
return ImmutableSortedSet.copyOf(elementComparator, collection);
}
示例4: propertyDescription
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
private static String propertyDescription(ModelSchemaExtractionContext<?> parentContext, ModelProperty<?> property) {
if (property.getDeclaredBy().size() == 1 && property.getDeclaredBy().contains(parentContext.getType())) {
return String.format("property '%s'", property.getName());
} else {
ImmutableSortedSet<String> declaredBy = ImmutableSortedSet.copyOf(Iterables.transform(property.getDeclaredBy(), Functions.toStringFunction()));
return String.format("property '%s' declared by %s", property.getName(), Joiner.on(", ").join(declaredBy));
}
}
示例5: toNaturalSortedSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Nonnull
private static <T> SortedSet<? extends T> toNaturalSortedSet(@Nonnull Collection<? extends T> collection) {
if (isNaturalSortedSet(collection)) {
return (SortedSet<? extends T>)collection;
}
return ImmutableSortedSet.copyOf(collection);
}
示例6: toSortedSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Nonnull
public ImmutableSortedSet<ImmutableItem> toSortedSet(@Nonnull Comparator<? super ImmutableItem> comparator,
@Nullable final Iterable<? extends Item> iterable) {
if (iterable == null) {
return ImmutableSortedSet.of();
}
boolean needsCopy = false;
if (iterable instanceof ImmutableSortedSet &&
((ImmutableSortedSet)iterable).comparator().equals(comparator)) {
for (Item element: iterable) {
if (!isImmutable(element)) {
needsCopy = true;
break;
}
}
} else {
needsCopy = true;
}
if (!needsCopy) {
return (ImmutableSortedSet<ImmutableItem>)iterable;
}
final Iterator<? extends Item> iter = iterable.iterator();
return ImmutableSortedSet.copyOf(comparator, new Iterator<ImmutableItem>() {
@Override public boolean hasNext() { return iter.hasNext(); }
@Override public ImmutableItem next() { return makeImmutable(iter.next()); }
@Override public void remove() { iter.remove(); }
});
}
示例7: ShortestPathTable
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
/**
* Constructor.
*
* The shortest path table will be computed upon construction.
*
* @param ontology
*/
public ShortestPathTable(Ontology<?, ?> ontology) {
termIdCount = ontology.getNonObsoleteTermIds().size();
distances = new int[termIdCount * termIdCount];
termIdToIdx = new HashMap<>(termIdCount);
int i = 0;
for (TermId termId : ImmutableSortedSet.copyOf(ontology.getNonObsoleteTermIds())) {
termIdToIdx.put(termId, i++);
}
precomputeDistances(ontology);
}
示例8: PrecomputedScores
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
PrecomputedScores(Collection<TermId> termIds) {
termIdCount = termIds.size();
data = new float[termIdCount * termIdCount];
termIdToIdx = new HashMap<>(termIdCount);
int i = 0;
for (TermId termId : ImmutableSortedSet.copyOf(termIds)) {
termIdToIdx.put(termId, i++);
}
}
示例9: test
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Test
public void test() {
Set<TermId> inputIds = Sets.newHashSet(id1);
Set<TermId> outputIds =
ImmutableSortedSet.copyOf(TermIds.augmentWithAncestors(ontology, inputIds, true));
assertEquals(
"[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000002], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000003], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000004], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000005]]",
outputIds.toString());
}
示例10: getAnnotations
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
public SortedSet<AnnotationMember> getAnnotations() {
return ImmutableSortedSet.copyOf(annotations);
}
示例11: getParameterAnnotations
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
public SortedSet<AnnotationMember> getParameterAnnotations() {
return ImmutableSortedSet.copyOf(parameterAnnotations);
}
示例12: create
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Override
public Set<UnhashableObject> create(UnhashableObject[] elements) {
return ImmutableSortedSet.copyOf(elements);
}
示例13: collectFieldsWritten
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
SortedSet<DexField> collectFieldsWritten() {
return ImmutableSortedSet.copyOf(PresortedComparable::slowCompareTo,
Sets.union(collectReachedFields(instanceFieldsWritten, this::tryLookupInstanceField),
collectReachedFields(staticFieldsWritten, this::tryLookupStaticField)));
}
示例14: create
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Override
protected SortedSet<String> create(String[] elements) {
return ImmutableSortedSet.copyOf(elements);
}
示例15: getReferenceCounts
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Override
ImmutableSortedSet<Integer> getReferenceCounts() {
return ImmutableSortedSet.copyOf(logFileIDReferenceCounts.keySet());
}