Example usage for com.google.common.collect ImmutableSortedMap of

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

Introduction

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

Prototype

@SuppressWarnings("unchecked")
    public static <K, V> ImmutableSortedMap<K, V> of() 

Source Link

Usage

From source file:com.spotify.heroic.metric.MetricReadResult.java

public static MetricReadResult create(final MetricCollection metrics) {
    return new MetricReadResult(metrics, ImmutableSortedMap.of());
}

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();
    }//from   w w w  .jav a2 s .com
    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:ec.tss.tsproviders.Util.java

static ImmutableSortedMap<String, String> toImmutable(Map<String, String> params) {
    switch (params.size()) {
    case 0://from  ww w  .  ja v  a 2  s  .c  o  m
        return ImmutableSortedMap.of();
    case 1:
        Map.Entry<String, String> first = params.entrySet().iterator().next();
        return ImmutableSortedMap.of(first.getKey(), first.getValue());
    default:
        return ImmutableSortedMap.copyOf(params);
    }
}

From source file:com.noodlewiz.xjavab.core.ValueParam.java

/**
 * Returns the empty ValueParam.
 */
public ValueParam() {
    mMap = ImmutableSortedMap.of();
}

From source file:org.gradle.api.internal.changedetection.state.InputPropertiesSerializer.java

public ImmutableSortedMap<String, ValueSnapshot> read(Decoder decoder) throws Exception {
    int size = decoder.readSmallInt();
    if (size == 0) {
        return ImmutableSortedMap.of();
    }//from  www  . j a v a 2 s .c om
    if (size == 1) {
        return ImmutableSortedMap.of(decoder.readString(), readSnapshot(decoder));
    }

    ImmutableSortedMap.Builder<String, ValueSnapshot> builder = ImmutableSortedMap.naturalOrder();
    for (int i = 0; i < size; i++) {
        builder.put(decoder.readString(), readSnapshot(decoder));
    }
    return builder.build();
}

From source file:com.facebook.buck.jvm.java.AbstractResourcesParameters.java

@Value.Default
@AddToRuleKey
public ImmutableSortedMap<String, SourcePath> getResources() {
    return ImmutableSortedMap.of();
}

From source file:com.edmunds.etm.runtime.api.ApplicationSeries.java

/**
 * Constructs a new {@code ApplicationSeries} with the specified name.
 *
 * @param name unique name of the application series
 *//*from w ww .  j a v  a 2  s  .c o  m*/
public ApplicationSeries(String name) {
    Validate.notEmpty(name, "Application series name is empty");
    this.name = name;
    this.applicationsByVersion = ImmutableSortedMap.of();
}

From source file:io.blobkeeper.common.util.Utils.java

public static MerkleTree createEmptyTree(@NotNull Range<Long> range, int depth) {
    MerkleTree tree = new MerkleTree(range, depth);
    MerkleTree.fillTree(tree, ImmutableSortedMap.of());
    tree.calculate();/*from w ww .ja va  2s . c om*/
    return tree;
}

From source file:org.gradle.api.internal.artifacts.transform.DefaultTransformerExecutionHistoryRepository.java

@Override
public void persist(HashCode cacheKey, OriginMetadata originMetadata,
        ImplementationSnapshot implementationSnapshot,
        ImmutableSortedMap<String, CurrentFileCollectionFingerprint> outputFingerprints, boolean successful) {
    executionHistoryStore.store(cacheKey.toString(), originMetadata, implementationSnapshot, ImmutableList.of(),
            ImmutableSortedMap.of(), ImmutableSortedMap.of(), outputFingerprints, successful);
}

From source file:com.addthis.codec.reflection.CodableClassInfo.java

public CodableClassInfo(@Nonnull Class<?> clazz, @Nonnull Config globalDefaults,
        @Nonnull PluginRegistry pluginRegistry) {

    // skip native classes
    if (Fields.isNative(clazz) || clazz.isArray()) {
        classData = ImmutableSortedMap.of();
        baseClass = clazz;//  ww w.  java2 s  .  c o  m
        pluginMap = PluginMap.EMPTY;
        fieldDefaults = ConfigFactory.empty();
        return;
    }

    // find any parent class (or itself) with a Pluggable annotation
    Class<?> findBaseClass = clazz;
    PluginMap findPluginMap = PluginMap.EMPTY;

    Class<?> ptr = clazz;
    while (ptr != null) {
        if (pluginRegistry.byClass().containsKey(ptr)) {
            findPluginMap = pluginRegistry.byClass().get(ptr);
            findBaseClass = ptr;
            break;
        }
        Pluggable pluggable = ptr.getAnnotation(Pluggable.class);
        if (pluggable != null) {
            String category = pluggable.value();
            findPluginMap = pluginRegistry.asMap().get(category);
            findBaseClass = ptr;
            if (findPluginMap == null) {
                log.warn("missing plugin map for {}, reached from {}", ptr, clazz);
                findPluginMap = PluginMap.EMPTY;
            }
            break;
        }
        ptr = ptr.getSuperclass();
    }
    pluginMap = findPluginMap;
    baseClass = findBaseClass;

    // find all fields in the class and its parent classes, and aggregate any defaults
    Map<String, Field> fields = new HashMap<>();
    // slower than using unwrapped, mutable conversions but this preserves origins
    ConfigObject buildDefaults = ConfigFactory.empty().root();

    Class<?> ptrForFields = clazz;
    while (ptrForFields != null) {
        String canonicalClassName = ptrForFields.getCanonicalName();
        ConfigObject classDefaults;
        if ((canonicalClassName != null) && globalDefaults.hasPath(canonicalClassName)) {
            classDefaults = globalDefaults.getObject(canonicalClassName);
        } else {
            classDefaults = ConfigFactory.empty().root();
        }
        for (Field field : ptrForFields.getDeclaredFields()) {
            if (fields.get(field.getName()) == null) {
                fields.put(field.getName(), field);
            } else {
                classDefaults = classDefaults.withoutKey(field.getName());
                log.debug("({}) ignoring field in parent class ({}) with duplicate name ({})", clazz,
                        ptrForFields, field.getName());
            }
        }
        for (Map.Entry<String, ConfigValue> pair : classDefaults.entrySet()) {
            if (!buildDefaults.containsKey(pair.getKey())) {
                buildDefaults = buildDefaults.withValue(pair.getKey(), pair.getValue());
            }
        }
        ptrForFields = ptrForFields.getSuperclass();
    }
    fieldDefaults = buildDefaults.toConfig();

    // turn all the found fields into CodableFieldInfo objects
    Map<String, CodableFieldInfo> buildClassData = buildFieldInfoMap(fields.values());
    classData = ImmutableSortedMap.<String, CodableFieldInfo>naturalOrder().putAll(buildClassData).build();
}