本文整理汇总了Java中java8.util.Lists.of方法的典型用法代码示例。如果您正苦于以下问题:Java Lists.of方法的具体用法?Java Lists.of怎么用?Java Lists.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java8.util.Lists
的用法示例。
在下文中一共展示了Lists.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureArrayCannotModifyList
import java8.util.Lists; //导入方法依赖的package包/类
@Test
public void ensureArrayCannotModifyList() {
String[] array = stringArray.clone();
List<String> list = Lists.of(array);
array[0] = "xyzzy";
assertEquals(list, Arrays.asList(stringArray));
}
示例2: nullDisallowed1
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed1() {
Lists.of((Object) null); // force one-arg overload
}
示例3: nullDisallowed2a
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2a() {
Lists.of("a", null);
}
示例4: nullDisallowed2b
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2b() {
Lists.of(null, "b");
}
示例5: nullDisallowed3
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed3() {
Lists.of("a", "b", null);
}
示例6: nullDisallowed4
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed4() {
Lists.of("a", "b", "c", null);
}
示例7: nullDisallowed5
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed5() {
Lists.of("a", "b", "c", "d", null);
}
示例8: nullDisallowed6
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed6() {
Lists.of("a", "b", "c", "d", "e", null);
}
示例9: nullDisallowed7
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed7() {
Lists.of("a", "b", "c", "d", "e", "f", null);
}
示例10: nullDisallowed8
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed8() {
Lists.of("a", "b", "c", "d", "e", "f", "g", null);
}
示例11: nullDisallowed9
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed9() {
Lists.of("a", "b", "c", "d", "e", "f", "g", "h", null);
}
示例12: nullDisallowed10
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed10() {
Lists.of("a", "b", "c", "d", "e", "f", "g", "h", "i", null);
}
示例13: nullDisallowedN
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowedN() {
String[] array = stringArray.clone();
array[0] = null;
Lists.of(array);
}
示例14: nullArrayDisallowed
import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullArrayDisallowed() {
Lists.of((Object[])null);
}
示例15: toUnmodifiableList
import java8.util.Lists; //导入方法依赖的package包/类
/**
* Returns a {@code Collector} that accumulates the input elements into an
* {@link Lists#of(Object[]) unmodifiable List} in encounter
* order. The returned Collector disallows null values and will throw
* {@code NullPointerException} if it is presented with a null value.
*
* @param <T> the type of the input elements
* @return a {@code Collector} which collects all the input elements into an
* <a href="../Lists.html#unmodifiable">unmodifiable List</a>, in encounter order
* @since 10
*/
@SuppressWarnings("unchecked")
public static <T>
Collector<T, ?, List<T>> toUnmodifiableList() {
return new CollectorImpl<>(arrayListNew(), listAdd(),
(left, right) -> { left.addAll(right); return left; },
list -> (List<T>) Lists.of(list.toArray()),
CH_NOID);
}