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


Java Map.ofEntries方法代码示例

本文整理汇总了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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Configuration.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:MapFactories.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:SystemModuleFinders.java

示例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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:VM.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:MapFactories.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:MapFactories.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:MapFactories.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:MapFactories.java

示例9: nullArrayDisallowed

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


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