Example usage for com.google.common.collect ImmutableMap.Builder put

List of usage examples for com.google.common.collect ImmutableMap.Builder put

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap.Builder put.

Prototype

public final V put(K k, V v) 

Source Link

Usage

From source file:co.runrightfast.core.security.crypto.impl.EncryptionServiceImpl.java

public static Map<String, Key> toKeyMap(@NonNull final SecretKeys keys) {
    final ImmutableMap.Builder<String, Key> mapBuilder = ImmutableMap.builder();
    keys.getKeys().entrySet().stream().forEach(entry -> mapBuilder.put(entry.getKey(),
            SerializationUtils.deserialize(entry.getValue().toByteArray())));
    return mapBuilder.build();
}

From source file:org.zalando.logbook.JsonHttpLogFormatter.java

private static <T> void addUnless(final ImmutableMap.Builder<String, Object> target, final String key,
        final T element, final Predicate<T> predicate) {

    if (!predicate.test(element)) {
        target.put(key, element);
    }//from  w ww  . java 2 s  . c om
}

From source file:com.spotify.missinglink.Simple.java

public static ImmutableMap<ClassTypeDescriptor, DeclaredClass> classMap(DeclaredClass... classes) {
    ImmutableMap.Builder<ClassTypeDescriptor, DeclaredClass> builder = ImmutableMap.builder();
    for (DeclaredClass clazz : classes) {
        builder.put(clazz.className(), clazz);
    }/*from   ww w  . j a  v a2 s . co m*/
    return builder.build();
}

From source file:com.spotify.missinglink.Simple.java

public static ImmutableMap<MethodDescriptor, DeclaredMethod> methodMap(DeclaredMethod... methods) {
    ImmutableMap.Builder<MethodDescriptor, DeclaredMethod> builder = ImmutableMap.builder();
    for (DeclaredMethod method : methods) {
        builder.put(method.descriptor(), method);
    }/*  ww w  .  j  a v a 2 s.  c om*/
    return builder.build();
}

From source file:org.gradle.internal.component.external.model.ivy.DefaultMutableIvyModuleResolveMetadata.java

private static ImmutableMap<String, Configuration> toMap(Collection<Configuration> configurations) {
    ImmutableMap.Builder<String, Configuration> builder = ImmutableMap.builder();
    for (Configuration configuration : configurations) {
        builder.put(configuration.getName(), configuration);
    }//  w  w w  .  j a v  a2 s  .co m
    return builder.build();
}

From source file:grakn.core.graql.gremlin.spanningtree.graph.DirectedEdge.java

public static Predicate<DirectedEdge> competesWith(final Set<DirectedEdge> required) {
    final ImmutableMap.Builder<Node, Node> requiredSourceByDestinationBuilder = ImmutableMap.builder();
    for (DirectedEdge edge : required) {
        requiredSourceByDestinationBuilder.put(edge.destination, edge.source);
    }//ww  w.  j a va  2s.c  om
    final Map<Node, Node> requiredSourceByDest = requiredSourceByDestinationBuilder.build();
    return input -> {
        assert input != null;
        return (requiredSourceByDest.containsKey(input.destination)
                && !input.source.equals(requiredSourceByDest.get(input.destination)));
    };
}

From source file:io.druid.segment.realtime.appenderator.Committed.java

public static Committed create(Map<SegmentIdentifier, Integer> hydrants0, Object metadata) {
    final ImmutableMap.Builder<String, Integer> hydrants = ImmutableMap.builder();
    for (Map.Entry<SegmentIdentifier, Integer> entry : hydrants0.entrySet()) {
        hydrants.put(entry.getKey().getIdentifierAsString(), entry.getValue());
    }//from   w w  w  .  ja v a 2s. c o  m
    return new Committed(hydrants.build(), metadata);
}

From source file:com.isotrol.impe3.core.impl.CookiesFactory.java

/**
 * Returns a coolection of cookies containing the provided cookies.
 * @param cookies Cookies to add to the collection.
 * @return The requested collection.//from  ww w .j a  v a2 s.  c  om
 * @throws NullPointerException if the argument is null.
 * @throws IllegalArgumentException if there are more than one cookie with the same name.
 */
public static Cookies of(Iterable<Cookie> cookies) {
    Preconditions.checkNotNull(cookies);
    final ImmutableMap.Builder<String, Cookie> builder = ImmutableMap.builder();
    for (final Cookie cookie : cookies) {
        builder.put(cookie.getName(), cookie);
    }
    return new Immutable(builder.build());
}

From source file:org.smartdeveloperhub.curator.connector.Filters.java

public static Filters of(final Collection<Filter> filters) {
    final ImmutableMap.Builder<URI, String> builder = ImmutableMap.<URI, String>builder();
    for (final Filter filter : filters) {
        builder.put(filter.property(), filter.variable().name());
    }//from  w  w w  .  j  a va  2 s  . com
    return new Filters(builder.build());
}

From source file:com.facebook.buck.model.FlavorDomain.java

/**
 * Create a FlavorDomain from FlavorConvertible objects.
 *//* w  w w . ja va 2s.  c o m*/
public static <T extends FlavorConvertible> FlavorDomain<T> from(String name, Iterable<T> objects) {
    ImmutableMap.Builder<Flavor, T> builder = ImmutableMap.builder();
    for (T value : objects) {
        builder.put(value.getFlavor(), value);
    }
    return new FlavorDomain<>(name, builder.build());
}