本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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());
}
示例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();
}
示例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()]));
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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()));
}
示例13: list
import java.util.List; //导入方法依赖的package包/类
public static List<String> list(String ... args){
System.out.println("Using factory methods");
return List.of(args);
}
示例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;
}
示例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);
}