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


Java Map.of方法代码示例

本文整理汇总了Java中java.util.Map.of方法的典型用法代码示例。如果您正苦于以下问题:Java Map.of方法的具体用法?Java Map.of怎么用?Java Map.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Map的用法示例。


在下文中一共展示了Map.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dumpJavaOptions

import java.util.Map; //导入方法依赖的package包/类
@Test
void dumpJavaOptions() {
  List<String> expectedLines =
      List.of(
          "java",
          "--dry-run",
          "--patch-module",
          "  com.greetings=xxx",
          "--module-path",
          "  mods",
          "--module",
          "  com.greetings/com.greetings.Main",
          "1",
          "2",
          "NEW");
  Bach.JdkTool.Java java = new Bach.JdkTool.Java();
  java.dryRun = true;
  java.patchModule = Map.of("com.greetings", List.of(Paths.get("xxx")));
  java.modulePath = List.of(Paths.get("mods"));
  java.module = "com.greetings/com.greetings.Main";
  java.args = List.of(1, "2", Thread.State.NEW);
  assertLinesMatch(expectedLines, dump(java.toCommand()));
}
 
开发者ID:sormuras,项目名称:bach,代码行数:24,代码来源:JdkToolTests.java

示例2: defaultDMHMethods

import java.util.Map; //导入方法依赖的package包/类
/**
 * @return the list of default DirectMethodHandle methods to generate.
 */
private static Map<String, Set<String>> defaultDMHMethods() {
    return Map.of(
        DMH_INVOKE_VIRTUAL, Set.of("L_L", "LL_L", "LLI_I", "L3_V"),
        DMH_INVOKE_SPECIAL, Set.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L",
            "L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "LLI_I", "LLI_L",
            "LLIL_I", "LLII_I", "LLII_L", "L3I_L", "L3I_I", "LLILI_I",
            "LLIIL_L", "LLIILL_L", "LLIILL_I", "LLIIL_I", "LLILIL_I",
            "LLILILL_I", "LLILII_I", "LLI3_I", "LLI3L_I", "LLI3LL_I",
            "LLI3_L", "LLI4_I"),
        DMH_INVOKE_STATIC, Set.of("LII_I", "LIL_I", "LILIL_I", "LILII_I",
            "L_I", "L_L", "L_V", "LD_L", "LF_L", "LI_I", "LII_L", "LLI_L",
            "LL_V", "LL_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L",
            "L8_L", "L9_L", "L10_L", "L10I_L", "L10II_L", "L10IIL_L",
            "L11_L", "L12_L", "L13_L", "L14_L", "L14I_L", "L14II_L")
    );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:GenerateJLIClassesPlugin.java

示例3: testAddExports

import java.util.Map; //导入方法依赖的package包/类
/**
 * Use redefineModule to update java.base to export jdk.internal.misc
 */
public void testAddExports() {
    Module baseModule = Object.class.getModule();
    Module thisModule = this.getClass().getClassLoader().getUnnamedModule();
    String pkg = "jdk.internal.misc";

    // pre-conditions
    assertFalse(baseModule.isExported(pkg));
    assertFalse(baseModule.isExported(pkg, thisModule));

    // update java.base to export jdk.internal.misc to an unnamed module
    Map<String, Set<Module>> extraExports = Map.of(pkg, Set.of(thisModule));
    redefineModule(baseModule, Set.of(), extraExports, Map.of(), Set.of(), Map.of());
    assertFalse(baseModule.isExported(pkg));
    assertTrue(baseModule.isExported(pkg, thisModule));
    assertFalse(baseModule.isOpen(pkg));
    assertFalse(baseModule.isOpen(pkg, thisModule));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:RedefineModuleTest.java

示例4: testAddOpens

import java.util.Map; //导入方法依赖的package包/类
/**
 * Use redefineModule to update java.base to open jdk.internal.loader
 */
public void testAddOpens() {
    Module baseModule = Object.class.getModule();
    Module thisModule = this.getClass().getClassLoader().getUnnamedModule();
    String pkg = "jdk.internal.loader";

    // pre-conditions
    assertFalse(baseModule.isOpen(pkg));
    assertFalse(baseModule.isOpen(pkg, thisModule));

    // update java.base to open dk.internal.loader to an unnamed module
    Map<String, Set<Module>> extraExports = Map.of(pkg, Set.of(thisModule));
    redefineModule(baseModule, Set.of(), Map.of(), extraExports, Set.of(), Map.of());
    assertFalse(baseModule.isExported(pkg));
    assertTrue(baseModule.isExported(pkg, thisModule));
    assertFalse(baseModule.isOpen(pkg));
    assertTrue(baseModule.isOpen(pkg, thisModule));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:RedefineModuleTest.java

示例5: testProvideServiceNotInModule

import java.util.Map; //导入方法依赖的package包/类
/**
 * Test redefineClass by attempting to update java.base to provide a service
 * where the service provider class is not in the module.
 */
@Test(expectedExceptions = IllegalArgumentException.class)
public void testProvideServiceNotInModule() {
    Module baseModule = Object.class.getModule();
    class MyProvider extends URLStreamHandlerProvider {
        @Override
        public URLStreamHandler createURLStreamHandler(String protocol) {
            return null;
        }
    }

    // attempt to update java.base to provide MyProvider
    Map<Class<?>, List<Class<?>>> extraProvides
        = Map.of(URLStreamHandlerProvider.class, List.of(MyProvider.class));
    redefineModule(baseModule, Set.of(), Map.of(), Map.of(), Set.of(), extraProvides);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:RedefineModuleTest.java

示例6: nullValueDisallowed2

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed2() {
    Map<Integer, String> map = Map.of(0, "a", 1, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java

示例7: nullValueDisallowed1

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed1() {
    Map<Integer, String> map = Map.of(0, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java

示例8: testExportPackageToEmptySet

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void testExportPackageToEmptySet() {
    // attempt to update java.base to export jdk.internal.misc to nobody
    Module baseModule = Object.class.getModule();
    Map<String, Set<Module>> extraExports = Map.of("jdk.internal.misc", Set.of());
    redefineModule(baseModule, Set.of(), extraExports, Map.of(), Set.of(), Map.of());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:RedefineModuleTest.java

示例9: nullKeyDisallowed7

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowed7() {
    Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
                                      5, "f", null, "g");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java

示例10: nullKeyDisallowed9

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowed9() {
    Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
                                      5, "f", 6, "g", 7, "h", null, "i");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java

示例11: get

import java.util.Map; //导入方法依赖的package包/类
public Map<String, List<String>>
    get(URI uri, Map<String, List<String>> requestHeaders)
    throws IOException
{
    // pre-condition check
    if (uri == null || requestHeaders == null) {
        throw new IllegalArgumentException("Argument is null");
    }

    // if there's no default CookieStore, no way for us to get any cookie
    if (cookieJar == null)
        return Map.of();

    boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
    List<HttpCookie> cookies = new java.util.ArrayList<>();
    String path = uri.getPath();
    if (path == null || path.isEmpty()) {
        path = "/";
    }
    for (HttpCookie cookie : cookieJar.get(uri)) {
        // apply path-matches rule (RFC 2965 sec. 3.3.4)
        // and check for the possible "secure" tag (i.e. don't send
        // 'secure' cookies over unsecure links)
        if (pathMatches(path, cookie.getPath()) &&
                (secureLink || !cookie.getSecure())) {
            // Enforce httponly attribute
            if (cookie.isHttpOnly()) {
                String s = uri.getScheme();
                if (!"http".equalsIgnoreCase(s) && !"https".equalsIgnoreCase(s)) {
                    continue;
                }
            }
            // Let's check the authorize port list if it exists
            String ports = cookie.getPortlist();
            if (ports != null && !ports.isEmpty()) {
                int port = uri.getPort();
                if (port == -1) {
                    port = "https".equals(uri.getScheme()) ? 443 : 80;
                }
                if (isInPortList(ports, port)) {
                    cookies.add(cookie);
                }
            } else {
                cookies.add(cookie);
            }
        }
    }

    // apply sort rule (RFC 2965 sec. 3.3.4)
    List<String> cookieHeader = sortByPath(cookies);

    return Map.of("Cookie", cookieHeader);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:CookieManager.java

示例12: nullValueDisallowed8

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed8() {
    Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
                                      5, "f", 6, "g", 7, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java

示例13: dupKeysDisallowed9

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowed9() {
    Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
                                      5, "f", 6, "g", 7, "h", 0, "i");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java

示例14: dupKeysDisallowed10

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowed10() {
    Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
                                      5, "f", 6, "g", 7, "h", 8, "i", 0, "j");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java

示例15: nullValueDisallowed5

import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed5() {
    Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java


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