本文整理汇总了Java中java.util.Map.ofEntries方法的典型用法代码示例。如果您正苦于以下问题:Java Map.ofEntries方法的具体用法?Java Map.ofEntries怎么用?Java Map.ofEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Map
的用法示例。
在下文中一共展示了Map.ofEntries方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Configuration
import java.util.Map; //导入方法依赖的package包/类
private Configuration(List<Configuration> parents, Resolver resolver) {
Map<ResolvedModule, Set<ResolvedModule>> g = resolver.finish(this);
@SuppressWarnings(value = {"rawtypes", "unchecked"})
Entry<String, ResolvedModule>[] nameEntries
= (Entry<String, ResolvedModule>[])new Entry[g.size()];
ResolvedModule[] moduleArray = new ResolvedModule[g.size()];
int i = 0;
for (ResolvedModule resolvedModule : g.keySet()) {
moduleArray[i] = resolvedModule;
nameEntries[i] = Map.entry(resolvedModule.name(), resolvedModule);
i++;
}
this.parents = Collections.unmodifiableList(parents);
this.graph = g;
this.modules = Set.of(moduleArray);
this.nameToModule = Map.ofEntries(nameEntries);
this.targetPlatform = resolver.targetPlatform();
}
示例2: entryWildcardTests
import java.util.Map; //导入方法依赖的package包/类
@Test
public void entryWildcardTests() {
Map.Entry<Integer,Double> e1 = Map.entry(1, 2.0);
Map.Entry<Float,Long> e2 = Map.entry(3.0f, 4L);
Map<Number,Number> map = Map.ofEntries(e1, e2);
assertEquals(map.size(), 2);
}
示例3: SystemModuleFinder
import java.util.Map; //导入方法依赖的package包/类
SystemModuleFinder(ModuleReference[] array,
Map.Entry<String, ModuleReference>[] map) {
this.mrefs = Set.of(array);
this.nameToModule = Map.ofEntries(map);
}
示例4: saveAndRemoveProperties
import java.util.Map; //导入方法依赖的package包/类
public static void saveAndRemoveProperties(Properties props) {
if (initLevel() != 0)
throw new IllegalStateException("Wrong init level");
@SuppressWarnings({"rawtypes", "unchecked"})
Map<String, String> sp =
Map.ofEntries(props.entrySet().toArray(new Map.Entry[0]));
// only main thread is running at this time, so savedProps and
// its content will be correctly published to threads started later
savedProps = sp;
// Set the maximum amount of direct memory. This value is controlled
// by the vm option -XX:MaxDirectMemorySize=<size>.
// The maximum amount of allocatable direct buffer memory (in bytes)
// from the system property sun.nio.MaxDirectMemorySize set by the VM.
// The system property will be removed.
String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
if (s != null) {
if (s.equals("-1")) {
// -XX:MaxDirectMemorySize not given, take default
directMemory = Runtime.getRuntime().maxMemory();
} else {
long l = Long.parseLong(s);
if (l > -1)
directMemory = l;
}
}
// Check if direct buffers should be page aligned
s = (String)props.remove("sun.nio.PageAlignDirectMemory");
if ("true".equals(s))
pageAlignDirectMemory = true;
// Remove other private system properties
// used by java.lang.Integer.IntegerCache
props.remove("java.lang.Integer.IntegerCache.high");
// used by sun.launcher.LauncherHelper
props.remove("sun.java.launcher.diag");
// used by jdk.internal.loader.ClassLoaders
props.remove("jdk.boot.class.path.append");
}
示例5: dupKeysDisallowedN
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowedN() {
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
entries[MAX_ENTRIES-1] = Map.entry(0, "xxx");
Map<Integer, String> map = Map.ofEntries(entries);
}
示例6: nullKeyDisallowedN
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowedN() {
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
entries[0] = new AbstractMap.SimpleImmutableEntry(null, "a");
Map<Integer, String> map = Map.ofEntries(entries);
}
示例7: nullValueDisallowedN
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowedN() {
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
entries[0] = new AbstractMap.SimpleImmutableEntry(0, null);
Map<Integer, String> map = Map.ofEntries(entries);
}
示例8: nullEntryDisallowedN
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullEntryDisallowedN() {
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
entries[5] = null;
Map<Integer, String> map = Map.ofEntries(entries);
}
示例9: nullArrayDisallowed
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullArrayDisallowed() {
Map.ofEntries(null);
}