本文整理汇总了Java中com.google.common.collect.ImmutableSortedSet.of方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSortedSet.of方法的具体用法?Java ImmutableSortedSet.of怎么用?Java ImmutableSortedSet.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableSortedSet
的用法示例。
在下文中一共展示了ImmutableSortedSet.of方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSortedSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Nonnull
public SortedSet<ImmutableItem> toSortedSet(@Nonnull Comparator<? super ImmutableItem> comparator,
@Nullable final SortedSet<? extends Item> sortedSet) {
if (sortedSet == null || sortedSet.size() == 0) {
return ImmutableSortedSet.of();
}
@SuppressWarnings("unchecked")
ImmutableItem[] newItems = (ImmutableItem[])new Object[sortedSet.size()];
int index = 0;
for (Item item: sortedSet) {
newItems[index++] = makeImmutable(item);
}
return ArraySortedSet.of(comparator, newItems);
}
示例2: testAddModuleShardConfiguration
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Test
public void testAddModuleShardConfiguration() throws Exception {
URI namespace = new URI("urn:opendaylight:test:oven");
String moduleName = "oven";
String shardName = "oven-shard";
String shardStrategyName = ModuleShardStrategy.NAME;
Collection<MemberName> shardMemberNames = ImmutableSortedSet.of(MEMBER_1, MEMBER_4, MEMBER_5);
configuration.addModuleShardConfiguration(new ModuleShardConfiguration(namespace, moduleName, shardName,
shardStrategyName, shardMemberNames));
assertEquals("getMemberShardNames", ImmutableSortedSet.of("people-1", "cars-1", "test-1", "default", shardName),
ImmutableSortedSet.copyOf(configuration.getMemberShardNames(MEMBER_1)));
assertEquals("getMemberShardNames", ImmutableSortedSet.of(shardName),
ImmutableSortedSet.copyOf(configuration.getMemberShardNames(MEMBER_4)));
assertEquals("getMemberShardNames", ImmutableSortedSet.of(shardName),
ImmutableSortedSet.copyOf(configuration.getMemberShardNames(MEMBER_5)));
assertEquals("getMembersFromShardName", shardMemberNames,
ImmutableSortedSet.copyOf(configuration.getMembersFromShardName(shardName)));
assertEquals("getShardNameForModule", shardName, configuration.getShardNameForModule(moduleName));
assertEquals("getModuleNameFromNameSpace", moduleName,
configuration.getModuleNameFromNameSpace(namespace.toASCIIString()));
assertEquals("getAllShardNames", ImmutableSortedSet.of("people-1", "cars-1", "test-1", "default", shardName),
ImmutableSortedSet.copyOf(configuration.getAllShardNames()));
ShardStrategy strategy = configuration.getStrategyForModule("cars");
assertNotNull("getStrategyForModule null", strategy);
assertEquals("getStrategyForModule type", ModuleShardStrategy.class, strategy.getClass());
}
示例3: ints
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Value.Default
ImmutableSet<Integer> ints() {
return ImmutableSortedSet.of();
}
示例4: generateImmutableSortedSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Generates private static <E extends Comparable<? super E>> ImmutableSortedSet<E>
generateImmutableSortedSet(E freshElement) {
return ImmutableSortedSet.of(freshElement);
}
示例5: nullToEmptySortedSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Nonnull public static <T> ImmutableSortedSet<T> nullToEmptySortedSet(@Nullable ImmutableSortedSet<T> set) {
if (set == null) {
return ImmutableSortedSet.of();
}
return set;
}