Example usage for com.google.common.collect Maps immutableEntry

List of usage examples for com.google.common.collect Maps immutableEntry

Introduction

In this page you can find the example usage for com.google.common.collect Maps immutableEntry.

Prototype

@GwtCompatible(serializable = true)
public static <K, V> Entry<K, V> immutableEntry(@Nullable K key, @Nullable V value) 

Source Link

Document

Returns an immutable map entry with the specified key and value.

Usage

From source file:org.icgc.dcc.download.server.service.RecordStatsService.java

private Map.Entry<DownloadDataType, Long> convertToBytes(Entry<DownloadDataType, Long> entry) {
    val type = entry.getKey();
    val value = entry.getValue();
    val weigth = recordWeights.get(type);

    return Maps.immutableEntry(type, value * weigth);
}

From source file:org.eclipse.sirius.common.ui.tools.internal.interpreter.VariableProposalProvider.java

@Override
public List<ContentProposal> getProposals(IInterpreter interpreter, ContentContext context) {
    final List<ContentProposal> proposals;
    if (context == null || !(interpreter instanceof VariableInterpreter)) {
        proposals = Collections.emptyList();
    } else {/*from ww  w .  ja  v  a2  s  .c o m*/
        // Transform Entry<String,VariableType> to Entry<String,String>
        Iterator<Entry<String, String>> variablesIterator = Iterators.transform(
                context.getInterpreterContext().getVariables().entrySet().iterator(),
                new Function<Map.Entry<String, VariableType>, Map.Entry<String, String>>() {

                    @Override
                    public Entry<String, String> apply(Entry<String, VariableType> input) {
                        return Maps.immutableEntry(input.getKey(), input.getValue().toString());
                    }

                });
        proposals = getProposals(context.getContents(), context.getPosition(), variablesIterator);
    }
    return proposals;
}

From source file:me.lucko.luckperms.sponge.commands.SpongeUtils.java

public static ContextSet convertContexts(Set<Context> contexts) {
    return ContextSet.fromEntries(contexts.stream().map(c -> Maps.immutableEntry(c.getKey(), c.getValue()))
            .collect(Collectors.toSet()));
}

From source file:org.apache.accumulo.server.replication.ReplicaSystemFactory.java

/**
 * Parse the configuration value for a peer into its components: {@link ReplicaSystem} class name and configuration string.
 *
 * @param value//from   w ww.ja v  a 2s .  c o m
 *          The configuration value for a replication peer.
 * @return An entry where the set is the replica system name and the value is the configuration string.
 */
public Entry<String, String> parseReplicaSystemConfiguration(String value) {
    requireNonNull(value);

    int index = value.indexOf(',');
    if (-1 == index) {
        throw new IllegalArgumentException(
                "Expected comma separator between replication system name and configuration");
    }

    String name = value.substring(0, index);
    String configuration = value.substring(index + 1);
    return Maps.immutableEntry(name, configuration);
}

From source file:me.lucko.luckperms.common.treeview.ImmutableTreeNode.java

public List<Map.Entry<Integer, String>> getNodeEndings() {
    if (children == null) {
        return Collections.emptyList();
    }/*from  w w  w .ja  v a 2 s .c  om*/

    List<Map.Entry<Integer, String>> results = new ArrayList<>();
    for (Map.Entry<String, ImmutableTreeNode> node : children.entrySet()) {

        // add self
        results.add(Maps.immutableEntry(0, node.getKey()));

        // add child nodes, incrementing their level & appending their prefix node
        results.addAll(node.getValue().getNodeEndings().stream().map(e -> Maps.immutableEntry(e.getKey() + 1, // increment level
                node.getKey() + "." + e.getValue())).collect(Collectors.toList()));
    }
    return results;
}

From source file:com.nesscomputing.config.ConfigJmxExporter.java

synchronized void export(Class<?> realClass, Object configBean) {
    MBeanServer server = this.server;
    if (server == null) {
        delayedBeanExports.add(Maps.immutableEntry(realClass, configBean));
        return;//  ww  w. j  a v  a2s  .  com
    }

    final String mungedName = munge(realClass.getName());
    if (!currentExports.add(mungedName)) {
        return; // Already exported
    }

    try {
        server.registerMBean(new ConfigMagicDynamicMBean(realClass.getName(), configBean),
                new ObjectName(mungedName));
    } catch (Exception e) {
        LOG.error("Unable to export config bean " + configBean.getClass().getName(), e);
    }
}

From source file:org.elasticsearch.common.collect.CopyOnWriteHashSet.java

/**
 * Copy the current set and return a copy that is the union of the current
 * set and <code>entries</code>, potentially replacing existing entries in
 * case of equality.//w  ww .jav a2s .  com
 */
public CopyOnWriteHashSet<T> copyAndAddAll(Collection<? extends T> entries) {
    final Collection<Entry<T, Boolean>> asMapEntries = Collections2.transform(entries,
            new Function<T, Map.Entry<T, Boolean>>() {
                @Override
                public Entry<T, Boolean> apply(T input) {
                    return Maps.immutableEntry(input, true);
                }
            });
    CopyOnWriteHashMap<T, Boolean> updated = this.map.copyAndPutAll(asMapEntries);
    return new CopyOnWriteHashSet<>(updated);
}

From source file:org.apache.james.dnsservice.library.MXHostAddressIterator.java

private static ImmutableMap.Entry<String, String> extractHostAndPort(String nextHostname, int defaultPort) {
    final String hostname;
    final String port;

    int idx = nextHostname.indexOf(':');
    if (idx > 0) {
        port = nextHostname.substring(idx + 1);
        hostname = nextHostname.substring(0, idx);
    } else {//from w  w  w .j a v a 2 s  .  co m
        hostname = nextHostname;
        port = Integer.toString(defaultPort);
    }
    return Maps.immutableEntry(hostname, port);
}

From source file:com.github.autermann.yaml.nodes.YamlPairsNode.java

@Override
public YamlPairsNode put(YamlNode key, YamlNode value) {
    // small protection adding this to a collection added to this still works
    if (key == this || value == this) {
        throw new IllegalArgumentException("recursive structures are currently not supported");
    }//www .  ja v  a  2s .  co  m
    this.value.add(Maps.immutableEntry(key, value));
    this.multiMap.put(key, value);
    return this;
}

From source file:ninja.leaping.permissionsex.bukkit.PEXVault.java

private Set<Map.Entry<String, String>> contextsFrom(@Nullable String world) {
    return world == null ? PermissionsEx.GLOBAL_CONTEXT : ImmutableSet.of(Maps.immutableEntry("world", world));
}