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

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

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.gradleware.tooling.toolingmodel.repository.internal.DefaultOmniBuildInvocationsContainer.java

private static void collectBuildInvocations(OmniGradleProject project,
        ImmutableSortedMap.Builder<Path, OmniBuildInvocations> result) {
    result.put(project.getPath(),
            DefaultOmniBuildInvocations.from(project.getProjectTasks(), project.getTaskSelectors()));

    List<OmniGradleProject> children = project.getChildren();
    for (OmniGradleProject child : children) {
        collectBuildInvocations(child, result);
    }/*from ww  w .  j  a  va  2 s.com*/
}

From source file:ec.tss.tsproviders.utils.ParamBean.java

@Nonnull
public static ImmutableSortedMap<String, String> toSortedMap(@Nullable ParamBean[] params) {
    if (params == null || params.length == 0) {
        return ImmutableSortedMap.of();
    }/* w ww.j av  a  2  s . co  m*/
    ImmutableSortedMap.Builder<String, String> b = ImmutableSortedMap.naturalOrder();
    for (ParamBean o : params) {
        b.put(Strings.nullToEmpty(o.key), Strings.nullToEmpty(o.value));
    }
    return b.build();
}

From source file:com.fatboyindustrial.omnium.Maps.java

/**
 * Transforms the given map by applying a function to each of the keys.
 * @param input The input map./*www  .  ja  v a 2  s  .  c  om*/
 * @param transform The transformation function to apply to the key.
 * @param <K1> The original key type.
 * @param <V> The map value type.
 * @param <K2> The transformed key type.
 * @return The new map.
 */
public static <K1 extends Comparable<K1>, V, K2 extends Comparable<K2>> ImmutableSortedMap<K2, V> keyTransform(
        final ImmutableSortedMap<K1, V> input, final Function<K1, K2> transform) {
    final ImmutableSortedMap.Builder<K2, V> builder = ImmutableSortedMap.naturalOrder();
    input.forEach((key, value) -> builder.put(transform.apply(key), value));
    return builder.build();
}

From source file:com.facebook.presto.block.BlockCursorAssertions.java

public static SortedMap<Integer, Tuple> toTuplesMap(BlockCursor cursor) {
    ImmutableSortedMap.Builder<Integer, Tuple> tuples = ImmutableSortedMap.naturalOrder();
    while (cursor.advanceNextPosition()) {
        tuples.put(cursor.getPosition(), cursor.getTuple());
    }/*from w  w  w  . j  a  va  2 s  .  c om*/
    return tuples.build();
}

From source file:com.facebook.buck.cli.AuditActionGraphCommand.java

private static ImmutableSortedMap<String, String> getNodeAttributes(BuildRule rule) {
    ImmutableSortedMap.Builder<String, String> attrs = ImmutableSortedMap.naturalOrder();
    attrs.put("short_name", rule.getBuildTarget().getShortName());
    attrs.put("type", rule.getType());
    attrs.put("output", rule.getSourcePathToOutput() == null ? "" : rule.getSourcePathToOutput().toString());
    attrs.put("cacheable", rule.isCacheable() ? "true" : "false");
    attrs.put("flavored", rule.getBuildTarget().isFlavored() ? "true" : "false");
    return attrs.build();
}

From source file:com.google.gcloud.datastore.PartialEntity.java

static PartialEntity fromPb(DatastoreV1.Entity entityPb) {
    ImmutableSortedMap.Builder<String, Value<?>> properties = ImmutableSortedMap.naturalOrder();
    for (DatastoreV1.Property property : entityPb.getPropertyList()) {
        properties.put(property.getName(), Value.fromPb(property.getValue()));
    }//from   ww  w. j  ava2  s  .c om
    PartialKey partialKey = null;
    if (entityPb.hasKey()) {
        partialKey = PartialKey.fromPb(entityPb.getKey());
        if (partialKey instanceof Key) {
            return new Entity((Key) partialKey, properties.build());
        }
    }
    return new PartialEntity(partialKey, properties.build());
}

From source file:com.gradleware.tooling.toolingmodel.repository.internal.DefaultOmniBuildInvocationsContainer.java

public static OmniBuildInvocationsContainer from(Map<String, BuildInvocations> buildInvocationsPerProject) {
    ImmutableSortedMap.Builder<Path, OmniBuildInvocations> buildInvocationsMap = ImmutableSortedMap
            .orderedBy(Path.Comparator.INSTANCE);
    for (String projectPath : buildInvocationsPerProject.keySet()) {
        buildInvocationsMap.put(Path.from(projectPath), DefaultOmniBuildInvocations
                .from(buildInvocationsPerProject.get(projectPath), Path.from(projectPath)));
    }// ww w  .ja v a  2s  .c  om
    return new DefaultOmniBuildInvocationsContainer(buildInvocationsMap.build());
}

From source file:com.google.gcloud.datastore.ProjectionEntity.java

static ProjectionEntity fromPb(DatastoreV1.Entity entityPb) {
    ImmutableSortedMap.Builder<String, Value<?>> properties = ImmutableSortedMap.naturalOrder();
    for (DatastoreV1.Property property : entityPb.getPropertyList()) {
        properties.put(property.getName(), Value.fromPb(property.getValue()));
    }/*from   w w w  . j a  v a2  s.  c o  m*/
    Key key = null;
    if (entityPb.hasKey()) {
        key = Key.fromPb(entityPb.getKey());
    }
    return new ProjectionEntity(key, properties.build());
}

From source file:com.google.idea.blaze.android.sync.importer.problems.GeneratedResourceClassifier.java

private static ImmutableSortedMap.Builder<ArtifactLocation, Integer> considerAllInteresting(
        Collection<ArtifactLocation> generatedResourceLocations) {
    ImmutableSortedMap.Builder<ArtifactLocation, Integer> builder = ImmutableSortedMap.naturalOrder();
    for (ArtifactLocation location : generatedResourceLocations) {
        builder.put(location, -1);
    }//w w  w.java 2 s .  c  o  m
    return builder;
}

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

private static Map<Integer, ?> iterableToSortedMap(Iterable<?> iterable) {
    // We use a sorted map here so that the iteration across the keySet is consistent.
    ImmutableSortedMap.Builder<Integer, Object> builder = new ImmutableSortedMap.Builder<>(Ordering.natural());
    int i = 0;// w  ww .ja va2s.  c om
    for (Object item : Iterables.filter(iterable, notNull())) {
        builder.put(i++, item);
    }
    return builder.build();
}