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:com.android.build.gradle.internal.incremental.fixture.ClassEnhancement.java

private static Map<String, File> getCompileFolders(File folder) throws IOException {
    Context context = InstrumentationRegistry.getContext();
    String[] names = context.getAssets().list(folder.getPath());
    ImmutableMap.Builder<String, File> builder = ImmutableMap.builder();

    for (String name : names) {
        builder.put(name, new File(folder, name));
    }/*from   w  w w. ja va 2  s.  c  o  m*/

    return builder.build();
}

From source file:org.spongepowered.server.launch.transformer.at.AccessTransformers.java

static ImmutableMap<String, ClassAccessModifiers> build() {
    final SrgRemapper remapper = VanillaLaunch.getRemapper();

    ImmutableMap.Builder<String, ClassAccessModifiers> builder = ImmutableMap.builder();
    for (Map.Entry<String, ClassAccessModifiers.Builder> entry : rules.entrySet()) {
        builder.put(entry.getKey(), entry.getValue().build(remapper));
    }/*w  w w .j av  a 2s .  co  m*/

    rules = null;
    return builder.build();
}

From source file:com.yahoo.yqlplus.engine.internal.plan.types.Conversions.java

static void registerMethod(ImmutableMap.Builder<String, BytecodeSequence> m, Class from, Class to,
        String method) {/*from   w w w. ja v a 2 s. c  o  m*/
    m.put(key(from, to), new ConvertCall(from, method, to));
}

From source file:google.registry.model.registry.Registries.java

/**
 * Returns a newly-created Supplier of a registries to types map.
 *
 * <p>The supplier's get() method enters a transactionless context briefly to avoid enrolling the
 * query inside an unrelated client-affecting transaction.
 *///from  www.  j  a v a  2s.  c om
private static Supplier<ImmutableMap<String, TldType>> createFreshCache() {
    return memoizeWithShortExpiration(new Supplier<ImmutableMap<String, TldType>>() {
        @Override
        public ImmutableMap<String, TldType> get() {
            return ofy().doTransactionless(new Work<ImmutableMap<String, TldType>>() {
                @Override
                public ImmutableMap<String, TldType> run() {
                    ImmutableMap.Builder<String, TldType> builder = new ImmutableMap.Builder<>();
                    for (Registry registry : ofy().load().type(Registry.class).ancestor(getCrossTldKey())) {
                        builder.put(registry.getTldStr(), registry.getTldType());
                    }
                    return builder.build();
                }
            });
        }
    });
}

From source file:google.registry.util.DiffUtils.java

private static Map<String, ?> stringToMap(String string) {
    ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
    int i = 0;/*from   www  .j  a  va 2 s .c  o m*/
    for (String item : Splitter.on('\n').split(string)) {
        builder.put("Line " + i++, item);
    }
    return builder.build();
}

From source file:brooklyn.rest.transform.EntityTransformer.java

public static EntitySummary entitySummary(Entity entity) {
    String applicationUri = "/v1/applications/" + entity.getApplicationId();
    String entityUri = applicationUri + "/entities/" + entity.getId();
    ImmutableMap.Builder<String, URI> lb = ImmutableMap.<String, URI>builder().put("self",
            URI.create(entityUri));
    if (entity.getParent() != null)
        lb.put("parent", URI.create(applicationUri + "/entities/" + entity.getParent().getId()));
    String type = entity.getEntityType().getName();
    lb.put("application", URI.create(applicationUri)).put("children", URI.create(entityUri + "/children"))
            .put("config", URI.create(entityUri + "/config")).put("sensors", URI.create(entityUri + "/sensors"))
            .put("effectors", URI.create(entityUri + "/effectors"))
            .put("policies", URI.create(entityUri + "/policies"))
            .put("activities", URI.create(entityUri + "/activities"))
            .put("locations", URI.create(entityUri + "/locations")).put("tags", URI.create(entityUri + "/tags"))
            .put("expunge", URI.create(entityUri + "/expunge")).put("rename", URI.create(entityUri + "/name"))
            .put("spec", URI.create(entityUri + "/spec"));

    if (entity.getCatalogItemId() != null) {
        lb.put("catalog", URI.create(
                "/v1/catalog/entities/" + WebResourceUtils.getPathFromVersionedId(entity.getCatalogItemId())));
    }/*from  w  w  w .  j a  v a  2s . c  o m*/

    if (entity.getIconUrl() != null)
        lb.put("iconUrl", URI.create(entityUri + "/icon"));

    return new EntitySummary(entity.getId(), entity.getDisplayName(), type, entity.getCatalogItemId(),
            lb.build());
}

From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3TypeDiffSimplePrinter.java

/**
 * Converts a {@link ImmutableList} of {@link Ds3EnumConstant} into an {@link ImmutableMap} of
 * enum values (i.e. names) and {@link Ds3EnumConstant}
 */// w  w w  .ja va  2s.  c o m
private static ImmutableMap<String, Ds3EnumConstant> toEnumConstantMap(
        final ImmutableList<Ds3EnumConstant> enumConstants) {
    if (isEmpty(enumConstants)) {
        return ImmutableMap.of();
    }
    final ImmutableMap.Builder<String, Ds3EnumConstant> builder = ImmutableMap.builder();
    enumConstants.forEach(enumConstant -> builder.put(enumConstant.getName(), enumConstant));
    return builder.build();
}

From source file:org.dishevelled.bio.assembly.gfa2.Segment.java

/**
 * Parse a segment GFA 2.0 record from the specified value.
 *
 * @param value value, must not be null/*from  w  w  w  . j  a v a2 s.  c  om*/
 * @return a segment GFA 2.0 record parsed from the specified value
 */
public static Segment valueOf(final String value) {
    checkNotNull(value);
    checkArgument(value.startsWith("S"), "value must start with S");
    List<String> tokens = Splitter.on("\t").splitToList(value);
    if (tokens.size() < 4) {
        throw new IllegalArgumentException("value must have at least four tokens, was " + tokens.size());
    }

    ImmutableMap.Builder<String, Tag> tags = ImmutableMap.builder();
    for (int i = 4; i < tokens.size(); i++) {
        Tag tag = Tag.valueOf(tokens.get(i));
        tags.put(tag.getName(), tag);
    }

    return new Segment(tokens.get(1), Integer.parseInt(tokens.get(2)), tokens.get(3), tags.build());
}

From source file:co.signal.loadgen.example.TagserveLoadGenerator.java

private static Map<String, Double> parseSiteWeights(Map<String, SiteConfig> configs) {
    double sum = 0;
    ImmutableMap.Builder<String, Double> siteWeights = ImmutableMap.builder();
    for (Map.Entry<String, SiteConfig> entry : configs.entrySet()) {
        sum += entry.getValue().getWeight();
        siteWeights.put(entry.getKey(), sum);
    }/*from w w w .  java 2s  . c  o  m*/
    if (sum != 1) {
        throw new RuntimeException("Site weights must sum to unity");
    }
    return siteWeights.build();
}

From source file:com.atlassian.jira.rest.client.IntegrationTestUtil.java

public static Map<String, URI> buildUserAvatarUris(@Nullable String user, Long avatarId) {
    final ImmutableMap.Builder<String, URI> builder = ImmutableMap.builder();
    for (String size : AVATAR_SIZE_TO_NAME_MAP.keySet()) {
        builder.put(size, buildUserAvatarUri(user, avatarId, size));
    }//from  w w w  . j a  va 2  s. co  m
    return builder.build();
}