當前位置: 首頁>>代碼示例>>Java>>正文


Java List.of方法代碼示例

本文整理匯總了Java中java.util.List.of方法的典型用法代碼示例。如果您正苦於以下問題:Java List.of方法的具體用法?Java List.of怎麽用?Java List.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.List的用法示例。


在下文中一共展示了List.of方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: includeLocaleFilePatterns

import java.util.List; //導入方法依賴的package包/類
private List<String> includeLocaleFilePatterns(String tag) {
    // Ignore extension variations
    if (tag.matches(".+-[a-z]-.+")) {
        return List.of();
    }

    List<String> files = new ArrayList<>(includeLocaleFiles(tag.replaceAll("-", "_")));

    // Add Thai BreakIterator related data files
    if (tag.equals("th")) {
        files.add(".+sun/text/resources/ext/thai_dict");
        files.add(".+sun/text/resources/ext/[^_]+BreakIteratorData_th");
    }

    // Add Taiwan resource bundles for Hong Kong
    if (tag.equals("zh-HK")) {
        files.addAll(includeLocaleFiles("zh_TW"));
    }

    return files;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:IncludeLocalesPlugin.java

示例2: intViewProvider

import java.util.List; //導入方法依賴的package包/類
@DataProvider
public static Object[][] intViewProvider() {
    List<Map.Entry<String, Function<ByteBuffer, IntBuffer>>> bfs = List.of(
            Map.entry("bb.asIntBuffer()",
                      bb -> bb.asIntBuffer()),
            Map.entry("bb.asIntBuffer().slice()",
                      bb -> bb.asIntBuffer().slice()),
            Map.entry("bb.asIntBuffer().slice().duplicate()",
                      bb -> bb.asIntBuffer().slice().duplicate())
    );

    return product(BYTE_BUFFER_FUNCTIONS, bfs);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:ByteBufferViews.java

示例3: main

import java.util.List; //導入方法依賴的package包/類
public static void main(String[] args)
        throws Throwable {

    String baseDir = System.getProperty("user.dir") + File.separator;
    String javac = JDKToolFinder.getTestJDKTool("javac");
    String java = JDKToolFinder.getTestJDKTool("java");

    setup(baseDir);
    String srcDir = System.getProperty("test.src");
    String cp = srcDir + File.separator + "a" + File.pathSeparator
            + srcDir + File.separator + "b.jar" + File.pathSeparator
            + ".";
    List<String[]> allCMDs = List.of(
            // Compile command
            new String[]{
                    javac, "-cp", cp, "-d", ".",
                    srcDir + File.separator + TEST_NAME + ".java"
            },
            // Run test the first time
            new String[]{
                    java, "-cp", cp, TEST_NAME, "1"
            },
            // Run test the second time
            new String[]{
                    java, "-cp", cp, TEST_NAME, "2"
            }
    );

    for (String[] cmd : allCMDs) {
        ProcessTools.executeCommand(cmd)
                    .outputTo(System.out)
                    .errorTo(System.out)
                    .shouldHaveExitValue(0);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:CheckSealedTest.java

示例4: normal4

import java.util.List; //導入方法依賴的package包/類
@Test
public void normal4() {
    BooleanAutoDisposable b1 = new BooleanAutoDisposable();
    BooleanAutoDisposable b2 = new BooleanAutoDisposable();

    CompositeAutoDisposable cd = new CompositeAutoDisposable(List.of(b1, b2));

    assertEquals(2, cd.size());

    cd.close();

    assertTrue(b1.isClosed());
    assertTrue(b2.isClosed());
}
 
開發者ID:akarnokd,項目名稱:Reactive4JavaFlow,代碼行數:15,代碼來源:CompositeAutoDisposableTest.java

示例5: compileMain

import java.util.List; //導入方法依賴的package包/類
void compileMain() {
  Bach.JdkTool.Javac javac = new Bach.JdkTool.Javac();
  javac.destination = MAIN;
  javac.modulePath = List.of(DEPS);
  javac.moduleSourcePath = List.of(Paths.get("src", "main", "java"));
  javac.run();
}
 
開發者ID:sormuras,項目名稱:bach,代碼行數:8,代碼來源:BuildDemo02Testing.java

示例6: testServer

import java.util.List; //導入方法依賴的package包/類
static void testServer(Class<?> test, String... args) throws Exception {
    List<String> extraArgsList = new ArrayList<>(
            List.of("-server", "-XX:-TieredCompilation"));
    extraArgsList.addAll(Arrays.asList(args));

    runTest(test, extraArgsList.toArray(new String[extraArgsList.size()]));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:ContinuousCallSiteTargetChange.java

示例7: run

import java.util.List; //導入方法依賴的package包/類
public void run(TestStream ts) {

        // start recording traces and trigger creation of the platform
        // MBeanServer to produce some. This won't work if the platform
        // MBeanServer was already initialized - so it's important to
        // run this test in its own JVM.
        ts.startRecording();
        MBeanServer platform = ManagementFactory.getPlatformMBeanServer();
        ts.stopRecording();
        String printed = ts.bos.toString();
        ts.bos.reset();

        // Check that the Platform MBeanServer is emitting the expected
        // log traces. This can be a bit fragile because debug traces
        // could be changed without notice - in which case this test will
        // need to be updated.
        // For each registered MBean we expect to see three traces.
        // If the messages logged by the MBeanServer change then these checks
        // may need to be revisited.
        List<String> checkTraces =
                List.of("ObjectName = %s", "name = %s", "JMX.mbean.registered %s");

        for (ObjectName o : platform.queryNames(ObjectName.WILDCARD, null)) {
            String n = o.toString();
            System.out.println("Checking log for: " + n);
            for (String check : checkTraces) {
                String s = String.format(check, n);
                if (!printed.contains(s)) {
                    throw new RuntimeException("Trace not found: " + s);
                }
            }
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:LoggingTest.java

示例8: main

import java.util.List; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    List<String> flags = List.of(
            "-version",
            "-Xinternalversion",
            "-X",
            "-help");
    for (String flag : flags) {
        ProcessTools.executeTestJvm(flag)
                    .shouldHaveExitValue(0);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:BasicVMTest.java

示例9: testDeprecatedModuleRequiresDeprecatedForRemovalModule

import java.util.List; //導入方法依賴的package包/類
@Test
public void testDeprecatedModuleRequiresDeprecatedForRemovalModule(Path base) throws Exception {
    Path moduleSrc = base.resolve("module-src");
    Path m1 = moduleSrc.resolve("src1/A");

    tb.writeJavaFiles(m1,
            "@Deprecated(forRemoval=true) module A { }");

    Path modulePath = base.resolve("module-path");

    Files.createDirectories(modulePath);

    new JavacTask(tb)
            .options("--module-source-path", m1.getParent().toString())
            .outdir(modulePath)
            .files(findJavaFiles(m1))
            .run()
            .writeAll();

    Path m2 = base.resolve("src2/B");

    tb.writeJavaFiles(m2,
            "@Deprecated(forRemoval=false) module B { requires A; }");
    List<String> log = new JavacTask(tb)
            .options("--module-source-path", m2.getParent().toString(),
                    "--module-path", modulePath.toString(),
                    "-XDrawDiagnostics")
            .outdir(modulePath)
            .files(findJavaFiles(m2))
            .run()
            .writeAll()
            .getOutputLines(OutputKind.DIRECT);

    List<String> expected = List.of("module-info.java:1:51: compiler.warn.has.been.deprecated.for.removal.module: A",
            "1 warning");
    if (!log.containsAll(expected)) {
        throw new AssertionError("Expected output not found. Expected: " + expected);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:40,代碼來源:AnnotationsOnModules.java

示例10: singleModuleValues

import java.util.List; //導入方法依賴的package包/類
@DataProvider(name = "singleModule")
public Object[][] singleModuleValues() throws IOException {
    Object[][] values = new Object[][]{
     // { Extra args to the build the message.converter jmod
     //   Tokens to pass to the run time --add-modules option
     //   SUCCESS or FAILURE expected
     //   Messages expected in the run time output
     //   Messages that must not appear in the run time output },
        { "",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("hello world", "message.converter", "java.base"),
          List.of("WARNING") },
        { "--do-not-resolve-by-default",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.base", "java.lang.ClassNotFoundException: converter.MessageConverter"),
          List.of("WARNING", "message.converter") },
        { "--warn-if-resolved=incubating",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("hello world", "message.converter", "java.base",
                  "WARNING: Using incubator modules: message.converter"),
          List.of() },
        { "--do-not-resolve-by-default --warn-if-resolved=incubating",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.base", "java.lang.ClassNotFoundException: converter.MessageConverter"),
          List.of("WARNING", "message.converter") },
        { "--do-not-resolve-by-default --warn-if-resolved=incubating",
          List.of("message.converter"),
          ToolResult.ASSERT_SUCCESS,
          List.of("hello world", "message.converter", "java.base", "WARNING"),
          List.of() }
    };
    return values;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:38,代碼來源:ImageModules.java

示例11: lookupWithIPv4Prefer

import java.util.List; //導入方法依賴的package包/類
static String lookupWithIPv4Prefer() throws IOException {
    String java = JDKToolFinder.getTestJDKTool("java");
    String testClz = Lookup.class.getName();
    List<String> cmd = List.of(java, "-Djava.net.preferIPv4Stack=true",
            "-cp", CLASS_PATH, testClz);
    System.out.println("Executing: " + cmd);
    return new OutputAnalyzer(new ProcessBuilder(cmd).start()).getOutput();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:Lookup.java

示例12: dumpJavadocOptions

import java.util.List; //導入方法依賴的package包/類
@Test
void dumpJavadocOptions() {
  List<String> expectedLines = List.of("javadoc", "-quiet");
  Bach.JdkTool.Javadoc javadoc = new Bach.JdkTool.Javadoc();
  javadoc.quiet = true;
  assertLinesMatch(expectedLines, dump(javadoc.toCommand()));
}
 
開發者ID:sormuras,項目名稱:bach,代碼行數:8,代碼來源:JdkToolTests.java

示例13: list

import java.util.List; //導入方法依賴的package包/類
public static List<String> list(String ... args){
	System.out.println("Using factory methods");
	return List.of(args);
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Cookbook,代碼行數:5,代碼來源:CollectionUtil.java

示例14: twoModulesValues

import java.util.List; //導入方法依賴的package包/類
@DataProvider(name = "twoModules")
public Object[][] twoModulesValues() throws IOException {
    Object[][] values = new Object[][]{
     // { Extra args to the build the message.writer jmod
     //   Extra args to the build the message.converter jmod
     //   Tokens to pass to the run time --add-modules option
     //   SUCCESS or FAILURE expected
     //   Messages expected in the run time output
     //   Messages that must not appear in the run time output },
        { "",
          "",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base"),
          List.of() },
        { "",
          "--do-not-resolve-by-default",
          List.of("ALL-DEFAULT", "ALL-SYSTEM"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base"),
          List.of() },
        { "--do-not-resolve-by-default",
          "",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.lang.ClassNotFoundException: writer.MessageWriter", "java.base"),
          List.of("message.writer") },
        { "--do-not-resolve-by-default",
          "--do-not-resolve-by-default",
          List.of("ALL-DEFAULT"),
          ToolResult.ASSERT_FAILURE,
          List.of("java.lang.ClassNotFoundException: writer.MessageWriter", "java.base"),
          List.of("message.converter", "message.writer") },
    // now add in warnings
        { "--do-not-resolve-by-default --warn-if-resolved=incubating",
          "",
          List.of("message.writer"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base",
                  "WARNING: Using incubator modules: message.writer"),
          List.of() },
        { "",
          "--do-not-resolve-by-default --warn-if-resolved=incubating",
          List.of("message.writer"),
          ToolResult.ASSERT_SUCCESS,
          List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base",
                  "WARNING: Using incubator modules: message.converter"),
          List.of() }
        };
    return values;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:52,代碼來源:ImageModules.java

示例15: longestParameterList

import java.util.List; //導入方法依賴的package包/類
private static List<Class<?>> longestParameterList(List<List<Class<?>>> lists) {
    final List<Class<?>> empty = List.of();
    return lists.stream().reduce((p, q) -> p.size() >= q.size() ? p : q).orElse(empty);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:MethodHandles.java


注:本文中的java.util.List.of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。