當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。