當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。