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:ddf.security.samlp.impl.SPMetadataParser.java

/**
 * @param spMetadata Metadata from the service provider either as the xml itself, a url to a
 *     service that returns the xml, or the path to a file with the xml starting with file:
 * @param bindingSet Set of supported bindings
 * @return Map of the service providers entity id and the entity information
 *///  w ww.j av  a  2 s . com
public static Map<String, EntityInformation> parse(@Nullable List<String> spMetadata, Set<Binding> bindingSet) {
    if (spMetadata == null) {
        return Collections.emptyMap();
    }

    Map<String, EntityInformation> spMap = new HashMap<>();
    try {
        MetadataConfigurationParser metadataConfigurationParser = new MetadataConfigurationParser(spMetadata,
                ed -> {
                    EntityInformation entityInfo = new EntityInformation.Builder(ed, bindingSet).build();
                    if (entityInfo != null) {
                        spMap.put(ed.getEntityID(), entityInfo);
                    }
                });

        spMap.putAll(metadataConfigurationParser.getEntityDescriptors().entrySet().stream()
                .map(e -> Maps.immutableEntry(e.getKey(),
                        new EntityInformation.Builder(e.getValue(), bindingSet).build()))
                .filter(e -> nonNull(e.getValue()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));

    } catch (IOException e) {
        LOGGER.warn("Unable to parse SP metadata configuration. Check the configuration for SP metadata.", e);
    }

    return spMap;
}

From source file:com.nesscomputing.cache.NonEvictingJvmCacheProvider.java

@Override
public void set(String namespace, Collection<CacheStore<byte[]>> stores,
        @Nullable CacheStatistics cacheStatistics) {
    for (CacheStore<byte[]> entry : stores) {
        LOG.trace("%s setting %s:%s", this, namespace, entry.getKey());
        Entry<String, String> key = Maps.immutableEntry(namespace, entry.getKey());
        byte[] value = entry.getData();
        if (value != null) {
            map.put(key, value);/*from  w  w w. j ava  2s. c o m*/
        } else {
            map.remove(key);
        }
    }
}

From source file:me.lucko.luckperms.common.contexts.ServerCalculator.java

@Override
public MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator) {
    accumulator.add(Maps.immutableEntry("server", config.get(ConfigKeys.SERVER)));
    return accumulator;
}

From source file:com.infinities.nova.policy.reducer.ExtendOrExprReducer.java

@Override
public Entry<String, BaseCheck> getEntry(List<Entry<String, BaseCheck>> entrys) {
    ((OrCheck) entrys.get(0).getValue()).addCheck(entrys.get(2).getValue());
    return Maps.immutableEntry("or_expr", entrys.get(0).getValue());
}

From source file:com.infinities.nova.policy.reducer.ExtendAndExprReducer.java

@Override
public Entry<String, BaseCheck> getEntry(List<Entry<String, BaseCheck>> entrys) {
    ((AndCheck) entrys.get(0).getValue()).addCheck(entrys.get(2).getValue());
    return Maps.immutableEntry("and_expr", entrys.get(0).getValue());
}

From source file:com.infinities.keystone4j.policy.reducer.MakeNotExprReducer.java

@Override
public Entry<String, BaseCheck> getEntry(List<Entry<String, BaseCheck>> entry) {
    BaseCheck notCheck = new NotCheck(entry.get(1).getValue());
    return Maps.immutableEntry("check", notCheck);
}

From source file:io.atomix.core.map.impl.DelegatingAsyncDistributedNavigableMap.java

private Map.Entry<K, V> convertEntry(Map.Entry<K, Versioned<V>> entry) {
    return entry == null ? null : Maps.immutableEntry(entry.getKey(), Versioned.valueOrNull(entry.getValue()));
}

From source file:org.n52.janmayen.component.AbstractSimilarityKeyRepository.java

protected void setProducers(Collection<Provider<C>> providers) {
    this.components = new HashSet<>(providers);
    this.componentsByKey = providers.stream().flatMap(p -> keysOf(p).map(k -> Maps.immutableEntry(k, p)))
            .collect(groupingBy(Entry::getKey, HashMap::new, mapping(Entry::getValue, toSet())));
}

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

/**
 * @param queueKey//from   ww  w .  j  a  v a2s  .co  m
 *          Key from the work queue
 * @return Components which created the queue key
 */
public static Entry<String, ReplicationTarget> fromQueueKey(String queueKey) {
    requireNonNull(queueKey);

    int index = queueKey.indexOf(KEY_SEPARATOR);
    if (-1 == index) {
        throw new IllegalArgumentException("Could not find expected separator in queue key '" + queueKey + "'");
    }

    String filename = queueKey.substring(0, index);

    int secondIndex = queueKey.indexOf(KEY_SEPARATOR, index + 1);
    if (-1 == secondIndex) {
        throw new IllegalArgumentException("Could not find expected separator in queue key '" + queueKey + "'");
    }

    int thirdIndex = queueKey.indexOf(KEY_SEPARATOR, secondIndex + 1);
    if (-1 == thirdIndex) {
        throw new IllegalArgumentException("Could not find expected seperator in queue key '" + queueKey + "'");
    }

    return Maps.immutableEntry(filename, new ReplicationTarget(queueKey.substring(index + 1, secondIndex),
            queueKey.substring(secondIndex + 1, thirdIndex), queueKey.substring(thirdIndex + 1)));
}

From source file:com.palantir.common.collect.MapEntries.java

public static <F, T, R> Function<Entry<F, R>, Entry<T, R>> applyKey(final Function<F, T> f) {
    return new Function<Map.Entry<F, R>, Map.Entry<T, R>>() {
        @Override/* w  w  w  .java 2s.co m*/
        public Entry<T, R> apply(Entry<F, R> from) {
            return Maps.immutableEntry(f.apply(from.getKey()), from.getValue());
        }
    };
}