本文整理匯總了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()));
}
示例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")
);
}
示例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));
}
示例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));
}
示例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);
}
示例6: nullValueDisallowed2
import java.util.Map; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed2() {
Map<Integer, String> map = Map.of(0, "a", 1, null);
}
示例7: nullValueDisallowed1
import java.util.Map; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed1() {
Map<Integer, String> map = Map.of(0, null);
}
示例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());
}
示例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");
}
示例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");
}
示例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);
}
示例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);
}
示例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");
}
示例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");
}
示例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);
}