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:com.nesscomputing.cache.MemcacheProvider.java

@Override
public Map<String, Boolean> add(final String namespace, final Collection<CacheStore<byte[]>> stores,
        @Nullable CacheStatistics cacheStatistics) {
    ImmutableMap.Builder<String, Boolean> builder = ImmutableMap.builder();
    List<CacheStore<byte[]>> validStores = Lists.newArrayListWithExpectedSize(stores.size());
    for (CacheStore<byte[]> store : stores) {
        if (validateWrite(store)) {
            validStores.add(store);//from w  w  w.  j  av a  2  s .  co m
        } else {
            builder.put(Maps.immutableEntry(store.getKey(), false));
        }
    }
    if (cacheStatistics != null) {
        cacheStatistics.incrementOversizedStores(stores.size() - validStores.size());
    }
    builder.putAll(processOps(namespace, true, validStores, ADD_CALLBACK));
    return builder.build();
}

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

private List<Map.Entry<String, String>> asTreeList() {
    String prefix = rootPosition.equals(".") ? "" : (rootPosition + ".");
    List<Map.Entry<String, String>> ret = new ArrayList<>();

    for (Map.Entry<Integer, String> s : view.getNodeEndings()) {
        if (s.getKey() > maxLevels) {
            continue;
        }/* w  w  w  .  ja v  a2 s .  c  o m*/

        String treeStructure = Strings.repeat("  ", s.getKey()) + " ";
        String node = prefix + s.getValue();

        ret.add(Maps.immutableEntry(treeStructure, node));
    }

    return ret;
}

From source file:com.infinities.keystone4j.token.provider.api.TokenProviderApiImpl.java

private void registerCallbackListeners() {
    Map<Actions, List<Entry<String, ? extends NotificationCallback>>> callbacks = new HashMap<Actions, List<Entry<String, ? extends NotificationCallback>>>();
    List<Entry<String, ? extends NotificationCallback>> deletedList = new ArrayList<Entry<String, ? extends NotificationCallback>>();
    deletedList.add(Maps.immutableEntry("OS-TRUST:trust", new TrustDeletedEventCallback()));
    deletedList.add(Maps.immutableEntry("user", new DeleteUserTokensCallback()));
    deletedList.add(Maps.immutableEntry("domain", new DeleteDomainTokensCallback()));
    callbacks.put(Actions.deleted, deletedList);

    List<Entry<String, ? extends NotificationCallback>> disabledList = new ArrayList<Entry<String, ? extends NotificationCallback>>();
    disabledList.add(Maps.immutableEntry("user", new DeleteUserTokensCallback()));
    disabledList.add(Maps.immutableEntry("domain", new DeleteDomainTokensCallback()));
    disabledList.add(Maps.immutableEntry("project", new DeleteProjectTokensCallback()));
    callbacks.put(Actions.disabled, disabledList);

    List<Entry<String, ? extends NotificationCallback>> internalList = new ArrayList<Entry<String, ? extends NotificationCallback>>();
    disabledList.add(Maps.immutableEntry(Notifications.INVALIDATE_USER_TOKEN_PERSISTENCE,
            new DeleteUserTokensCallback()));
    disabledList.add(Maps.immutableEntry(Notifications.INVALIDATE_USER_PROJECT_TOKEN_PERSISTENCE,
            new DeleteUserProjectTokensCallback()));
    disabledList.add(Maps.immutableEntry(Notifications.INVALIDATE_USER_OAUTH_CONSUMER_TOKENS,
            new DeleteUserOauthConsumerTokensCallback()));
    callbacks.put(Actions.internal, internalList);

    for (Entry<Actions, List<Entry<String, ? extends NotificationCallback>>> entry : callbacks.entrySet()) {
        Actions event = entry.getKey();/*from  ww  w .  j a v a2s.com*/
        List<Entry<String, ? extends NotificationCallback>> cbInfos = entry.getValue();
        for (Entry<String, ? extends NotificationCallback> cbInfo : cbInfos) {
            String resourceType = cbInfo.getKey();
            NotificationCallback callbackFns = cbInfo.getValue();
            Notifications.registerEventCallback(event, resourceType, callbackFns);
        }
    }
}

From source file:com.palantir.atlasdb.jackson.AtlasDeserializers.java

private static Iterable<Entry<Cell, byte[]>> deserializeCellVal(TableMetadata metadata, JsonNode node) {
    byte[] row = deserializeRow(metadata.getRowMetadata(), node.get("row"));
    ColumnMetadataDescription colDescription = metadata.getColumns();
    if (colDescription.hasDynamicColumns()) {
        byte[] col = deserializeDynamicCol(colDescription.getDynamicColumn(), node.get("col"));
        byte[] val = deserializeVal(colDescription.getDynamicColumn().getValue(), node.get("val"));
        return ImmutableList.of(Maps.immutableEntry(Cell.create(row, col), val));
    } else {/*  w  w w  .  j a v a 2  s.co  m*/
        Collection<Entry<Cell, byte[]>> results = Lists.newArrayListWithCapacity(1);
        Iterator<Entry<String, JsonNode>> fields = node.fields();
        while (fields.hasNext()) {
            Entry<String, JsonNode> entry = fields.next();
            String longName = entry.getKey();
            if (longName.equals("row")) {
                continue;
            }
            NamedColumnDescription description = getNamedCol(colDescription, longName);
            byte[] col = PtBytes.toCachedBytes(description.getShortName());
            JsonNode valNode = entry.getValue();
            byte[] val = deserializeVal(description.getValue(), valNode);
            results.add(Maps.immutableEntry(Cell.create(row, col), val));
        }
        return results;
    }
}

From source file:org.openhab.binding.ekozefir.internal.EkozefirBinding.java

private Map.Entry<String, String> clearAndCheckConfig(String key, String value) throws ConfigurationException {
    if (StringUtils.isBlank(key)) {
        throw new ConfigurationException(key, "Blank key");
    }/*from w w w  . j a v a2  s.com*/
    if (StringUtils.isBlank(value)) {
        throw new ConfigurationException(value, "Blank value");
    }
    return Maps.immutableEntry(StringUtils.trim(key), StringUtils.trim(value));
}

From source file:org.apache.zeppelin.cluster.ClusterStateMachine.java

@Override
public void restore(BackupInput reader) {
    if (logger.isDebugEnabled()) {
        logger.debug("ClusterStateMachine.restore()");
    }// w w  w. j  av a2s.com

    clusterMeta = new ClusterMeta();
    // read all ServerMeta size
    int nServerMeta = reader.readInt();
    for (int i = 0; i < nServerMeta; i++) {
        // read cluster_name
        String clusterName = reader.readString();

        // read cluster mate kv pairs size
        int nKVpairs = reader.readInt();
        for (int j = 0; j < nKVpairs; i++) {
            // read cluster mate kv pairs
            String key = reader.readString();
            Object value = reader.readObject();

            clusterMeta.put(ClusterMetaType.ServerMeta, clusterName, Maps.immutableEntry(key, value));
        }
    }

    // read all IntpProcessMeta size
    int nIntpMeta = reader.readInt();
    for (int i = 0; i < nIntpMeta; i++) {
        // read interpreter name
        String intpName = reader.readString();

        // read interpreter mate kv pairs size
        int nKVpairs = reader.readInt();
        for (int j = 0; j < nKVpairs; i++) {
            // read interpreter mate kv pairs
            String key = reader.readString();
            Object value = reader.readObject();

            clusterMeta.put(ClusterMetaType.IntpProcessMeta, intpName, Maps.immutableEntry(key, value));
        }
    }
}

From source file:alluxio.conf.AlluxioProperties.java

/**
 * @return the entry set of all Alluxio property key and value pairs (value can be null)
 *///www . j a va  2  s.  com
public Set<Map.Entry<PropertyKey, String>> entrySet() {
    return keySet().stream().map(key -> Maps.immutableEntry(key, get(key))).collect(toSet());
}

From source file:org.learningu.scheduling.util.bst.BstMap.java

private static <K, V> Entry<K, V> tipOrNull(BstInOrderPath<TreapNode<K, V>> path) {
    return (path == null) ? null : Maps.immutableEntry(path.getTip().getKey(), path.getTip().getValue());
}

From source file:fi.vm.sade.organisaatio.business.impl.OrganisaatioBusinessChecker.java

public void checkParentChildHierarchy(Organisaatio organisaatio, Organisaatio parentOrg) {
    LOG.debug("checkParentChildHierarchy()");

    final OrganisationHierarchyValidator validator = new OrganisationHierarchyValidator(rootOrganisaatioOid);

    if (validator.apply(Maps.immutableEntry(parentOrg, organisaatio)) == false) {
        throw new OrganisaatioHierarchyException();
    }//from  ww  w  .ja va 2s  . c o m
}

From source file:org.onosproject.store.primitives.impl.TranscodingAsyncConsistentMap.java

@Override
public CompletableFuture<Set<Entry<K1, Versioned<V1>>>> entrySet() {
    return backingMap.entrySet().thenApply(s -> s.stream().map(
            e -> Maps.immutableEntry(keyDecoder.apply(e.getKey()), versionedValueTransform.apply(e.getValue())))
            .collect(Collectors.toSet()));
}