本文整理匯總了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;
}