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

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

Introduction

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

Prototype

Collection<V> get(@Nullable K key);

Source Link

Document

Returns a view collection of the values associated with key in this multimap, if any.

Usage

From source file:com.netflix.governator.lifecycle.LifecycleMethods.java

private void processField(Field field, Class<? extends Annotation> annotationClass,
        Multimap<Class<? extends Annotation>, String> usedNames) {
    if (field.isAnnotationPresent(annotationClass)) {
        if (!usedNames.get(annotationClass).contains(field.getName())) {
            field.setAccessible(true);/*ww w . j a  v  a  2  s. c o  m*/
            usedNames.put(annotationClass, field.getName());
            fieldMap.put(annotationClass, field);
        }
    }
}

From source file:com.facebook.buck.android.WriteAppModuleMetadataStep.java

private void writeModuleToStringsMultimap(Multimap<APKModule, String> map, Collection<String> dest) {
    for (APKModule dexStore : map.keySet()) {
        dest.add(MODULE_INDENTATION + dexStore.getName());
        for (String item : map.get(dexStore)) {
            dest.add(ITEM_INDENTATION + item);
        }// w ww. ja va2s  . c  o  m
    }
}

From source file:org.spongepowered.api.item.merchant.VillagerRegistry.java

/**
 * Gets the available {@link TradeOfferListMutator}s for the desired
 * {@link Career} and {@code level}.//  w ww.java 2  s. c om
 *
 * @param career The career
 * @param level The level
 * @return The collection of trade offer mutators, if available
 */
default Collection<TradeOfferListMutator> getMutatorsForCareer(Career career, int level) {
    final Multimap<Integer, TradeOfferListMutator> map = getTradeOfferLevelMap(
            checkNotNull(career, "Career cannot be null!"));
    final Collection<TradeOfferListMutator> mutators = map.get(level);
    return ImmutableList.copyOf(mutators);
}

From source file:org.jboss.errai.ioc.rebind.ioc.bootstrapper.ProducerFactoryBodyGenerator.java

@Override
protected List<Statement> generateCreateInstanceStatements(final ClassStructureBuilder<?> bodyBlockBuilder,
        final Injectable injectable, final DependencyGraph graph, final InjectionContext injectionContext) {
    final Multimap<DependencyType, Dependency> depsByType = separateByType(injectable.getDependencies());
    if (depsByType.get(DependencyType.ProducerMember).size() != 1) {
        throw new RuntimeException("A produced type must have exactly 1 producing instance but "
                + depsByType.get(DependencyType.ProducerMember).size() + " were found.");
    }//from  w w w .j a v a 2 s. co m
    final ProducerInstanceDependency producerInstanceDep = (ProducerInstanceDependency) depsByType
            .get(DependencyType.ProducerMember).iterator().next();
    final Injectable producerInjectable = producerInstanceDep.getInjectable();
    final MetaClassMember producingMember = producerInstanceDep.getProducingMember();

    if (producingMember instanceof MetaField) {
        return fieldCreateInstanceStatements((MetaField) producingMember, producerInjectable, injectable,
                bodyBlockBuilder);
    } else if (producingMember instanceof MetaMethod) {
        return methodCreateInstanceStatements((MetaMethod) producingMember, producerInjectable, injectable,
                depsByType.get(DependencyType.ProducerParameter), bodyBlockBuilder);
    } else {
        throw new RuntimeException("Unrecognized producing member: " + producingMember);
    }
}

From source file:foo.domaintest.http.HttpApiModule.java

@Provides
@Param("status")//w  w w  .  j av a  2 s .  co  m
Integer provideStatus(Multimap<String, String> params, @EasterEggs String easterEggUrl) {
    if (easterEggUrl == null) {
        String statusString = getFirst(params.get("status"), null);
        return statusString == null ? null : parseInt(statusString);
    }
    return HttpServletResponse.SC_FOUND;
}

From source file:net.myrrix.online.eval.AUCEvaluator.java

@Override
public EvaluationResult evaluate(MyrrixRecommender recommender, RescorerProvider provider, // ignored
        Multimap<Long, RecommendedItem> testData) throws TasteException {
    FastByIDMap<FastIDSet> converted = new FastByIDMap<FastIDSet>(testData.size());
    for (long userID : testData.keySet()) {
        Collection<RecommendedItem> userTestData = testData.get(userID);
        FastIDSet itemIDs = new FastIDSet(userTestData.size());
        converted.put(userID, itemIDs);/* w  w w.  j a v a 2  s .  c o  m*/
        for (RecommendedItem datum : userTestData) {
            itemIDs.add(datum.getItemID());
        }
    }
    return evaluate(recommender, converted);
}

From source file:org.clusion.DynRHAndroid.java

public static TreeMultimap<String, byte[]> tokenUpdate(byte[] key, Multimap<String, String> lookup)
        throws InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException,
        NoSuchProviderException, NoSuchPaddingException, IOException {

    // We use a lexicographic sorted list such that the server
    // will not know any information of the inserted elements creation order
    TreeMultimap<String, byte[]> tokenUp = TreeMultimap.create(Ordering.natural(), Ordering.usingToString());

    // Key generation
    for (String word : lookup.keySet()) {

        byte[] key2 = CryptoPrimitivesAndroid.generateCmac(key, 2 + word);
        // generate keys for response-hiding construction for SIV (Synthetic
        // IV)//from  w ww . j a  va  2  s. c  om
        byte[] key3 = CryptoPrimitivesAndroid.generateCmac(key, 3 + new String());

        byte[] key4 = CryptoPrimitivesAndroid.generateCmac(key, 4 + word);

        byte[] key5 = CryptoPrimitivesAndroid.generateCmac(key, 5 + word);

        for (String id : lookup.get(word)) {
            int counter = 0;

            if (state.get(word) != null) {
                counter = state.get(word);
            }

            state.put(word, counter + 1);

            byte[] l = CryptoPrimitivesAndroid.generateCmac(key5, "" + counter);

            String value = new String(CryptoPrimitivesAndroid.DTE_encryptAES_CTR_String(key3, key4, id, 20),
                    "ISO-8859-1");

            tokenUp.put(new String(l), CryptoPrimitivesAndroid.encryptAES_CTR_String(key2,
                    CryptoPrimitivesAndroid.randomBytes(16), value, sizeOfFileIdentifer));

        }

    }
    return tokenUp;
}

From source file:com.netflix.governator.lifecycle.LifecycleMethods.java

private void processMethod(Method method, Class<? extends Annotation> annotationClass,
        Multimap<Class<? extends Annotation>, String> usedNames) {
    if (method.isAnnotationPresent(annotationClass)) {
        if (!usedNames.get(annotationClass).contains(method.getName())) {
            /* TODO//  w  w  w  .j  a v  a2s  .c  o m
                            if ( method.getParameterTypes().length != 0 )
                            {
            throw new UnsupportedOperationException(String.format("@PostConstruct/@PreDestroy methods cannot have arguments: %s", method.getDeclaringClass().getName() + "." + method.getName() + "(...)"));
                            }
            */

            method.setAccessible(true);
            usedNames.put(annotationClass, method.getName());
            methodMap.put(annotationClass, method);
        }
    }
}

From source file:edu.tufts.vue.zotero.ZoteroWindow.java

public void load() {
    fileOpen = true;//  w w  w .j  a v  a2 s  . com
    java.util.List<Resource> libraries = new ArrayList<Resource>();
    Connection conn = null;
    ResultSet rs = null;
    try {
        Class.forName("org.sqlite.JDBC");

        conn = DriverManager.getConnection(
                "jdbc:sqlite://Users/mkorcy01//Library/Application Support/Firefox/Profiles/311aivcq.default/zotero/zotero.sqlite");
        Statement stat = conn.createStatement();
        conn.setAutoCommit(true);
        rs = stat.executeQuery("select * from collections;");
        java.util.List<ZoteroCollection> list = new ArrayList<ZoteroCollection>();

        while (rs.next()) {
            System.out.println("name = " + rs.getString("collectionName"));
            //               libraries.add(Resource.instance(rs.getString("collectionName")));
            ResourceNode collectionNode = new ResourceNode(Resource.instance(rs.getString("collectionName")));

            ZoteroCollection zColl = getItemsForCollection(conn, rs.getString("collectionName"),
                    rs.getInt("collectionID"));

            java.util.List<ZoteroItem> itemList = zColl.getItemList();

            Iterator<ZoteroItem> itemListIterator = itemList.iterator();

            while (itemListIterator.hasNext()) {
                ZoteroItem zItem = itemListIterator.next();
                Multimap<String, String> itemMap = zItem.getAttributeMap();
                Collection c = itemMap.get("title");
                Iterator<String> i = c.iterator();
                String title = null;
                if (i.hasNext())
                    title = i.next();
                else
                    title = "no title";
                System.out.println("Add item node, " + title);
                Resource res = Resource.instance(title);
                res.addProperty("things", "value");
                collectionNode.add(new ResourceNode(res));
            }
            rootNode.add(collectionNode);
        }
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (rs != null)
                rs.close();
            if (conn != null)
                conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    favoritesTree = new ZoteroDandDTree(rootNode);
    favoritesTree.setRootVisible(true);
    favoritesTree.expandRow(0);
    favoritesTree.setRootVisible(false);
    this.setFavoritesTree(favoritesTree);
}

From source file:org.jclouds.json.internal.IgnoreNullMultimapTypeAdapterFactory.java

private <K, V> TypeAdapter<Multimap<K, V>> newMapAdapter(final TypeAdapter<K> keyAdapter,
        final TypeAdapter<V> valueAdapter) {
    return new TypeAdapter<Multimap<K, V>>() {
        public void write(JsonWriter out, Multimap<K, V> map) throws IOException {
            out.beginObject();//from  www.  j  a v  a2 s .com
            for (K key : map.keySet()) {
                out.name(String.valueOf(key));
                out.beginArray();
                for (V value : map.get(key)) {
                    valueAdapter.write(out, value);
                }
                out.endArray();
            }
            out.endObject();
        }

        public Multimap<K, V> read(JsonReader in) throws IOException {
            ImmutableMultimap.Builder<K, V> result = ImmutableListMultimap.builder();
            in.beginObject();
            while (in.hasNext()) {
                JsonReaderInternalAccess.INSTANCE.promoteNameToValue(in);
                K name = keyAdapter.read(in);
                in.beginArray();
                while (in.hasNext()) {
                    V value = valueAdapter.read(in);
                    if (value != null)
                        result.put(name, value);
                }
                in.endArray();
            }
            in.endObject();
            return result.build();
        }
    }.nullSafe();
}