Example usage for com.google.common.collect ImmutableMap entrySet

List of usage examples for com.google.common.collect ImmutableMap entrySet

Introduction

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

Prototype

public final ImmutableSet<Entry<K, V>> entrySet() 

Source Link

Usage

From source file:models.Parameter.java

public static Map.Entry<Parameter, String> select(ImmutableMap<Parameter, String> params) {
    for (Map.Entry<Parameter, String> p : params.entrySet())
        if (isDefined(p.getValue()))
            return p;
    return null;/*from w w  w .ja v  a  2s  . c  o  m*/
}

From source file:org.prebake.util.ObjUtil.java

public static boolean isDeeplyImmutable(ImmutableMap<?, ?> m) {
    for (Map.Entry<?, ?> e : m.entrySet()) {
        if (!(isDeeplyImmutable(e.getKey()) && isDeeplyImmutable(e.getValue()))) {
            return false;
        }//from   w  w w  .  ja  v  a  2 s .co  m
    }
    return true;
}

From source file:com.fizzbuzz.vroom.core.api.util.UriHelper.java

public static String formatUriTemplate(final String uriTemplate, final Map<String, String> uriTokenToValueMap) {
    String result = uriTemplate;/*from  www. j a va 2s .c  om*/

    // make an defensive immutable copy of the provided map
    ImmutableMap<String, String> iMap = ImmutableMap.copyOf(uriTokenToValueMap);

    for (Map.Entry<String, String> entry : iMap.entrySet()) {
        result = result.replace(tokenize(entry.getKey()), entry.getValue());
    }
    return result;
}

From source file:org.quickgeo.generate.TemplateWriter.java

public static void writeTemplates(ImmutableMap<String, InputStream> input) {
    for (Entry<String, InputStream> entry : input.entrySet()) {
        writeTemplate(entry.getKey(), entry.getValue());
    }//from  w  w w .ja va 2  s. c o m
}

From source file:com.facebook.buck.core.rules.configsetting.ConfigSettingSelectable.java

private static boolean calculateMatches(BuckConfig buckConfig, ConstraintResolver constraintResolver,
        Platform targetPlatform, Collection<BuildTarget> constraintValuesTargets,
        ImmutableMap<String, String> values) {
    for (Map.Entry<String, String> entry : values.entrySet()) {
        if (!matches(buckConfig, entry.getKey(), entry.getValue())) {
            return false;
        }//ww  w . j a  v a  2  s  . com
    }
    ImmutableList<ConstraintValue> constraintValues = constraintValuesTargets.stream()
            .map(constraintResolver::getConstraintValue).collect(ImmutableList.toImmutableList());
    return targetPlatform.matchesAll(constraintValues);
}

From source file:keywhiz.cli.configs.AddOrUpdateActionConfig.java

private static void validateMetadata(ImmutableMap<String, String> metadata) {
    for (ImmutableMap.Entry<String, String> entry : metadata.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();

        // We want to perform strong validation of the metadata to make sure it is well formed.
        if (!key.matches("(owner|group|mode)")) {
            if (!key.startsWith("_")) {
                throw new IllegalArgumentException(format(
                        "Illegal metadata key %s: custom metadata keys must start with an underscore", key));
            }//w w  w .j av  a2  s  .  c  o  m
            if (!key.matches("^[a-zA-Z_0-9\\-.:]+$")) {
                throw new IllegalArgumentException(format(
                        "Illegal metadata key %s: metadata keys can only contain: a-z A-Z 0-9 _ - . :", key));
            }
        }

        if (key.equals("mode") && !value.matches("0[0-7]+")) {
            throw new IllegalArgumentException(format("mode %s is not proper octal", value));
        }
    }
}

From source file:org.zanata.rest.service.TransMemoryTMXExportStrategy.java

private static void addAttributes(Element toElem, ImmutableMap<String, String> attributes) {
    for (Map.Entry<String, String> attr : attributes.entrySet()) {
        toElem.addAttribute(toAttribute(attr));
    }/*from  w ww.  j a  v  a  2s .  c om*/
}

From source file:org.quickgeo.generate.Generate.java

License:asdf

private static ImmutableMap<String, InputStream> convertToStreams(ImmutableMap<String, File> map) {
    ImmutableMap.Builder<String, InputStream> builder = new ImmutableMap.Builder<String, InputStream>();

    for (Entry<String, File> entry : map.entrySet()) {
        String cc = entry.getKey();
        File zipFile = entry.getValue();
        try {//from w w  w  . ja  v a2 s. c  o  m
            ZipFile zf = new ZipFile(zipFile);
            ZipEntry ze = zf.getEntry(cc + ".txt");
            if (ze != null) {
                builder.put(cc, zf.getInputStream(ze));
            }
        } catch (Exception ex) {
            Settings.getSettings().getLogger().log(Level.WARNING, "Couldn't parse entry for " + cc, ex);
        }

    }

    return builder.build();
}

From source file:com.facebook.buck.rules.args.Arg.java

public static <K> ImmutableMap<K, String> stringify(ImmutableMap<K, Arg> argMap) {
    ImmutableMap.Builder<K, String> stringMap = ImmutableMap.builder();
    for (Map.Entry<K, Arg> ent : argMap.entrySet()) {
        ImmutableList.Builder<String> builder = ImmutableList.builder();
        ent.getValue().appendToCommandLine(builder);
        stringMap.put(ent.getKey(), Joiner.on(" ").join(builder.build()));
    }/*  ww w . j a v  a2  s  . c o  m*/
    return stringMap.build();
}

From source file:keywhiz.cli.commands.CreateOrUpdateAction.java

private static void validateMetadata(ImmutableMap<String, String> metadata) {
    for (ImmutableMap.Entry<String, String> entry : metadata.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();

        // We want to perform strong validation of the metadata to make sure it is well formed.
        if (!key.matches("(owner|group|mode)")) {
            throw new IllegalArgumentException(format("Illegal metadata key %s", key));
        }/*from  w  w w. ja va 2 s  . c  o  m*/

        if (key.equals("mode") && !value.matches("0[0-7]+")) {
            throw new IllegalArgumentException(format("mode %s is not proper octal", value));
        }
    }
}