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

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

Introduction

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

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:Dictconvert.java

public static void main(String args[]) throws Exception {

    final ImmutableMap<String, String> nameMap = new ImmutableMap.Builder<String, String>()
            .put("ebucoreMainFramework", "ebucoreMainFramework")
            .put("ebucorePartFramework", "ebucorePartFramework")
            .put("ebucoreMetadataSchemeInformation", "ebucoreMetadataSchemeInformation")
            /* List mainly generated using AWK:
               awk '{t=$2; gsub(/ebucore/, "", t); print "\x27"$2"\x27:\x27" tolower(substr(t, 1, 1))substr(t, 2)"\x27," }' < tmp.txt > tmpout.txt
            *///from w w w  .j a va 2s .  c o m
            .put("ebucoreEntity", "entity").put("ebucoreContact", "contact")
            .put("ebucoreContactDetails", "details").put("ebucoreAddress", "address")
            .put("ebucoreRegion", "region").put("ebucoreCompoundName", "compoundName")
            .put("ebucoreRole", "role").put("ebucoreCountry", "country")
            .put("ebucoreTextualAnnotation", "textualAnnotation").put("ebucoreBasicLink", "basicLink")
            .put("ebucoreTypeGroup", "typeGroup").put("ebucoreOrganisation", "organisation")
            .put("ebucoreOrganisationDepartment", "organisationDepartment")
            .put("ebucoreCoreMetadata", "coreMetadata").put("ebucoreIdentifier", "identifier")
            .put("ebucoreTitle", "title").put("ebucoreAlternativeTitle", "alternativeTitle")
            .put("ebucoreFormatGroup", "formatGroup").put("ebucoreStatusGroup", "statusGroup")
            .put("ebucoreSubject", "subject").put("ebucoreDescription", "description")
            .put("ebucoreDate", "date").put("ebucoreDateType", "dateType").put("ebucoreType", "type")
            .put("ebucoreObjectType", "objectType").put("ebucoreGenre", "genre")
            .put("ebucoreTargetAudience", "targetAudience").put("ebucoreLanguage", "language")
            .put("ebucoreCoverage", "coverage").put("ebucoreSpatial", "spatial")
            .put("ebucoreLocation", "location").put("ebucoreCoordinates", "coordinates")
            .put("ebucoreTemporal", "temporal").put("ebucorePeriodOfTime", "periodOfTime")
            .put("ebucoreRights", "rights").put("ebucoreVersion", "version").put("ebucoreRating", "rating")
            .put("ebucorePublicationHistoryEvent", "publicationHistoryEvent")
            .put("ebucorePublicationHistory", "publicationHistory")
            .put("ebucorePublicationChannel", "publicationChannel")
            .put("ebucorePublicationMedium", "publicationMedium")
            .put("ebucorePublicationService", "publicationService")
            .put("ebucoreCustomRelation", "customRelation").put("ebucoreBasicRelation", "basicRelation")
            .put("ebucorePartMetadata", "partMetadata").put("ebucoreFormat", "format")
            .put("ebucoreVideoFormat", "videoFormat").put("ebucoreImageFormat", "imageFormat")
            .put("ebucoreAudioFormat", "audioFormat").put("ebucoreTrack", "track")
            .put("ebucoreDataFormat", "dataFormat").put("ebucoreCaptioning", "captioning")
            .put("ebucoreSubtitling", "subtitling").put("ebucoreAncillaryData", "ancillaryData")
            .put("ebucoreSigningFormat", "signingFormat")
            .put("ebucoreTechnicalAttributeString", "technicalAttributeString")
            .put("ebucoreTechnicalAttributeInt8", "technicalAttributeInt8")
            .put("ebucoreTechnicalAttributeInt16", "technicalAttributeInt16")
            .put("ebucoreTechnicalAttributeInt32", "technicalAttributeInt32")
            .put("ebucoreTechnicalAttributeInt64", "technicalAttributeInt64")
            .put("ebucoreTechnicalAttributeUInt8", "technicalAttributeUInt8")
            .put("ebucoreTechnicalAttributeUInt16", "technicalAttributeUInt16")
            .put("ebucoreTechnicalAttributeUInt32", "technicalAttributeUInt32")
            .put("ebucoreTechnicalAttributeUInt64", "technicalAttributeUInt64")
            .put("ebucoreTechnicalAttributeFloat", "technicalAttributeFloat")
            .put("ebucoreTechnicalAttributeRational", "technicalAttributeRational")
            .put("ebucoreTechnicalAttributeAnyURI", "technicalAttributeAnyURI")
            .put("ebucoreTechnicalAttributeBoolean", "technicalAttributeBoolean")
            .put("ebucoreDimension", "dimension").put("ebucoreWidth", "width").put("ebucoreHeight", "height")
            .put("ebucorePackageInfo", "packageInfo").put("ebucoreMedium", "medium")
            .put("ebucoreCodec", "codec").put("ebucoreRational", "rational")
            .put("ebucoreAspectRatio", "aspectRatio").build();

    String key_ns_ebucore_1 = "urn:ebu:metadata-schema:smpteclass13/groups/ebucore_2013";
    Map<String, String> namespaces = ImmutableMap.<String, String>of(key_ns_ebucore_1, "key_ns_ebucore_1");

    HashMap<String, String> keys = new HashMap<String, String>();
    DocumentBuilderFactory builderF = DocumentBuilderFactory.newInstance();
    builderF.setNamespaceAware(true);

    DocumentBuilder builder = builderF.newDocumentBuilder();
    Document xmlDictionary = builder.parse(args[0]);

    Map<String, String> localKeys = new HashMap<String, String>();

    for (Map.Entry<String, String> e : namespaces.entrySet()) {
        System.out.println("XMLCh " + e.getValue() + "[] = {" + Joiner.on(",")
                .join(Iterables.transform(Lists.charactersOf(e.getKey()), new Function<Character, String>() {
                    public String apply(Character o) {
                        return "\'" + o + "\'";
                    }
                })) + ",\'\\0\'};");
    }

    for (Element e : Iterables.filter(getElements(xmlDictionary.getDocumentElement()),
            new Predicate<Element>() {
                public boolean apply(Element element) {
                    return element.getAttribute("type").equals("localSet");
                }
            })) {
        String name = nameMap.get(e.getLocalName());
        String keyName = "key_" + Joiner.on("").join(e.getAttribute("key").split("\\s"));

        localKeys.put(keyName, keyName + "_name");

        System.out.println("const mxfKey " + keyName + " = {" + Joiner.on(",").join(Iterables
                .transform(Arrays.asList(e.getAttribute("key").split("\\s")), new Function<String, String>() {
                    public String apply(String o) {
                        return "0x" + o;
                    }
                })) + "};");
        System.out.println("const XMLCh " + keyName + "_name[] = {" + Joiner.on(",")
                .join(Iterables.transform(Lists.charactersOf(name), new Function<Character, String>() {
                    public String apply(Character o) {
                        return "\'" + o + "\'";
                    }
                })) + ",\'\\0\'};");

        //System.out.println("st434dict.insert(std::pair<const mxfKey, st434info*>(");
        //System.out.println('\t' + keyName + ',');
        //System.out.println("\tnew st434info(/* " + e.getLocalName() + " */ " + keyName + "_name, /* " + key_ns_ebucore_1 + " */ " + namespaces.get(key_ns_ebucore_1) + ")");
        //System.out.println("));");

    }

    if (localKeys.size() > 0) {
        String arrayName = "arr_ebucore_elems";
        System.out.println("const void* " + arrayName + "[][2] = {");

        System.out.println(Joiner.on(", \n").join(
                Iterables.transform(localKeys.entrySet(), new Function<Map.Entry<String, String>, String>() {
                    @Override
                    public String apply(java.util.Map.Entry<String, String> e) {
                        return "{ &" + e.getKey() + ", " + e.getValue() + " }";
                    }
                })));
        System.out.println("};");

        System.out.println("for (int i=0; i<" + localKeys.size() + ";i++) {");
        System.out.println("\tst434dict.insert(std::pair<const mxfKey, st434info*>(");
        System.out.println("\t*(const mxfKey*)" + arrayName + "[i][0], ");
        System.out.println("\tnew st434info((const XMLCh*)" + arrayName + "[i][1], key_ns_ebucore_1)");
        System.out.println("));");
        System.out.println("}");
    }

}

From source file:com.eharmony.matching.seeking.query.criterion.SymbolicLookup.java

public static <T extends Symbolic> T resolve(String symbol, ImmutableMap<String, T> map, Class<T> clss) {
    T symbolic = map.get(symbol);
    if (symbolic == null) {
        throw new IllegalArgumentException(symbol + " is not a valid " + clss.getSimpleName() + " symbol");
    }//from  ww w.j  a  v  a2s.com
    return symbolic;
}

From source file:com.android.build.gradle.integration.common.utils.NdkHelper.java

/** Gets the maximum platform version supported by the specified ndk directory. */
public static int getMaxPlatformSupported(File ndkDir) {
    Revision ndkRevision = NdkHandler.findRevision(ndkDir);
    int major = ndkRevision != null ? ndkRevision.getMajor() : 10;
    // for r10 max platform is 21, r11 max is 24, r12 max platform is 24
    ImmutableMap<Integer, Integer> perVersion = ImmutableMap.of(10, 21, 11, 24, 12, 24, 13, 24);
    return perVersion.get(major);
}

From source file:com.facebook.buck.artifact_cache.AbstractArtifactCacheEventFactory.java

private static TargetConfiguration getTargetConfigurationFromMetadata(
        TargetConfigurationSerializer targetConfigurationSerializer, ImmutableMap<String, String> metadata) {
    String configuration = metadata.get(CONFIGURATION_KEY);
    if (Strings.isNullOrEmpty(configuration)) {
        return EmptyTargetConfiguration.INSTANCE;
    }// w  w  w . j a va  2 s. co  m
    return targetConfigurationSerializer.deserialize(configuration);
}

From source file:com.google.caliper.runner.worker.trial.TrialModule.java

@Provides
static Host provideHost(Target target, ImmutableMap<Target, Host> hostsByTarget) {
    return hostsByTarget.get(target);
}

From source file:com.facebook.buck.rules.KnownBuildRuleTypesTestUtil.java

@VisibleForTesting
public static List<String> getPaths(ImmutableMap<String, String> environemnt) {
    String pathEnv = environemnt.get("PATH");
    if (pathEnv == null) {
        return Collections.emptyList();
    }//from  w  w w.  j  a v a2s .c o  m

    return Arrays.asList(pathEnv.split(File.pathSeparator));
}

From source file:net.oneandone.neo.datareplicator.utils.Utils.java

public static void assertMapEntryEquals(ImmutableMap<String, String> m1, ImmutableMap<String, String> m2,
        String name) {/*from  w  ww.j  a v  a 2 s.co  m*/
    Assert.assertEquals(m1.get(name), m2.get(name));
}

From source file:com.google.idea.blaze.base.sync.workspace.BlazeRoots.java

private static String getOrThrow(BuildSystem buildSystem, ImmutableMap<String, String> map, String key) {
    String value = map.get(key);
    if (value == null) {
        throw new RuntimeException(
                String.format("Could not locate %s in %s info", key, buildSystem.getLowerCaseName()));
    }//from   w w w  . j a  v  a  2s.c  o  m
    return value;
}

From source file:org.locationtech.geogig.porcelain.index.IndexUtils.java

public static NodeRef resolveTypeTreeRef(Context context, String treeRefSpec) {
    checkArgument(treeRefSpec != null, "type tree was not provided");
    final String rootRef;
    final String treePath;
    final int rootSepIndex = treeRefSpec.indexOf(':');
    if (-1 == rootSepIndex) {
        rootRef = "HEAD";
        treePath = treeRefSpec;/*from  w  w w .  j  a  v  a 2  s .c o m*/
    } else {
        rootRef = treeRefSpec.substring(0, rootSepIndex);
        treePath = treeRefSpec.substring(rootSepIndex + 1);
    }
    List<NodeRef> treeRefs = context.command(FindFeatureTypeTrees.class).setRootTreeRef(rootRef).call();
    ImmutableMap<String, NodeRef> map = Maps.uniqueIndex(treeRefs, (r) -> r.path());
    NodeRef treeRef = map.get(treePath);
    checkArgument(treeRef != null, "Can't find feature tree '%s'", treeRefSpec);
    return treeRef;
}

From source file:com.facebook.buck.artifact_cache.AbstractArtifactCacheEventFactory.java

public static Optional<BuildTarget> getTarget(
        Function<String, UnconfiguredBuildTarget> unconfiguredBuildTargetFactory,
        TargetConfigurationSerializer targetConfigurationSerializer, ImmutableMap<String, String> metadata) {
    return metadata.containsKey(TARGET_KEY)
            ? getTarget(unconfiguredBuildTargetFactory, metadata.get(TARGET_KEY),
                    getTargetConfigurationFromMetadata(targetConfigurationSerializer, metadata))
            : Optional.empty();//from  ww w. j av  a 2 s.co m
}