当前位置: 首页>>代码示例>>Java>>正文


Java Lists.of方法代码示例

本文整理汇总了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));
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:8,代码来源:ListFactories.java

示例2: nullDisallowed1

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed1() {
    Lists.of((Object) null); // force one-arg overload
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例3: nullDisallowed2a

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2a() {
    Lists.of("a", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例4: nullDisallowed2b

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2b() {
    Lists.of(null, "b");
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例5: nullDisallowed3

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed3() {
    Lists.of("a", "b", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例6: nullDisallowed4

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed4() {
    Lists.of("a", "b", "c", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例7: nullDisallowed5

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed5() {
    Lists.of("a", "b", "c", "d", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例8: nullDisallowed6

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed6() {
    Lists.of("a", "b", "c", "d", "e", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例9: nullDisallowed7

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed7() {
    Lists.of("a", "b", "c", "d", "e", "f", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例10: nullDisallowed8

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed8() {
    Lists.of("a", "b", "c", "d", "e", "f", "g", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例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);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例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);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例13: nullDisallowedN

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowedN() {
    String[] array = stringArray.clone();
    array[0] = null;
    Lists.of(array);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:7,代码来源:ListFactories.java

示例14: nullArrayDisallowed

import java8.util.Lists; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullArrayDisallowed() {
    Lists.of((Object[])null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例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);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:20,代码来源:Collectors.java


注:本文中的java8.util.Lists.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。