List of usage examples for com.google.common.collect Multimap entries
Collection<Map.Entry<K, V>> entries();
From source file:hu.bme.mit.incqueryd.engine.rete.nodes.TypeInputNode.java
private void initializeProperty(final String typeName, RDFGraphDriverRead driver) throws IOException { Multimap<Resource, Value> properties = driver.collectProperties(typeName); for (Entry<Resource, Value> property : properties.entries()) { tuples.add(new Tuple(property.getKey().stringValue(), property.getValue().stringValue())); }//from ww w.j ava2 s . co m }
From source file:at.ac.univie.isc.asio.junit.IsMultimapContaining.java
@Override protected void describeMismatchSafely(final Multimap<K, V> item, final Description mismatchDescription) { mismatchDescription.appendText("map was ").appendValueList("[", ", ", "]", item.entries()); }
From source file:org.jclouds.scriptbuilder.domain.PipeHttpResponseTo.java
/** * // w ww. j a v a2 s . c o m * @param toExec * what to invoke * @param method * http method: ex GET * @param endpoint * uri corresponding to the request * @param headers * request headers to send */ public PipeHttpResponseTo(Statement toExec, String method, URI endpoint, Multimap<String, String> headers) { super(String.format("%s -X %s %s %s |(%s)\n", SaveHttpResponseTo.CURL, method, Joiner.on(' ') .join(Iterables.transform(headers.entries(), new Function<Entry<String, String>, String>() { @Override public String apply(Entry<String, String> from) { return String.format("-H \"%s: %s\"", from.getKey(), from.getValue()); } })), endpoint.toASCIIString(), toExec.render(OsFamily.UNIX))); }
From source file:com.pidoco.juri.JURI.java
public static CharSequence buildQueryParametersString(Multimap<String, String> currentQueryParameters) { StringBuilder paramsString = new StringBuilder(); boolean first = true; for (Map.Entry<String, String> entry : currentQueryParameters.entries()) { if (!first) { paramsString.append('&'); }/*from ww w . ja v a 2s. c om*/ String keyEnc = UrlEscapers.urlFormParameterEscaper().escape(entry.getKey()); if (entry.getValue() != null) { String valueEnc = UrlEscapers.urlFormParameterEscaper().escape(entry.getValue()); paramsString.append(keyEnc).append('=').append(valueEnc); } else { paramsString.append(keyEnc); } first = false; } return paramsString; }
From source file:org.shaf.core._helper_.DummyData.java
@SuppressWarnings({ "rawtypes" }) public final DummyData generateFor(final Multimap<KEY, VALUE> multimap) { for (Map.Entry<KEY, VALUE> entry : multimap.entries()) { this.data.put(entry.getKey(), entry.getValue()); }//from www . ja v a 2 s.co m return this; }
From source file:com.google.errorprone.bugpatterns.threadsafety.StaticGuardedByInstance.java
@Override public Description matchSynchronized(SynchronizedTree tree, VisitorState state) { Symbol lock = ASTHelpers.getSymbol(TreeInfo.skipParens((JCTree) tree.getExpression())); if (!(lock instanceof VarSymbol)) { return Description.NO_MATCH; }//w w w .j a v a2 s.co m if (lock.isStatic()) { return Description.NO_MATCH; } Multimap<VarSymbol, Tree> writes = WriteVisitor.scan(tree.getBlock()); for (Entry<VarSymbol, Tree> write : writes.entries()) { if (!write.getKey().isStatic()) { continue; } state.reportMatch(buildDescription(write.getValue()).setMessage(String.format(MESSAGE, lock)).build()); } return Description.NO_MATCH; }
From source file:com.palantir.atlasdb.keyvalue.cassandra.CQLExpiringKeyValueService.java
@Override public void putWithTimestamps(String tableName, Multimap<Cell, Value> values, final long time, final TimeUnit unit) { try {/* ww w .j a va 2 s .c o m*/ putInternal(tableName, values.entries(), TransactionType.NONE, CassandraKeyValueServices.convertTtl(time, unit), false); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } }
From source file:net.myrrix.online.eval.EstimatedStrengthEvaluator.java
@Override public EvaluationResult evaluate(MyrrixRecommender recommender, RescorerProvider provider, // ignored Multimap<Long, RecommendedItem> testData) throws TasteException { DoubleWeightedMean score = new DoubleWeightedMean(); int count = 0; for (Map.Entry<Long, RecommendedItem> entry : testData.entries()) { long userID = entry.getKey(); RecommendedItem itemPref = entry.getValue(); try {/*from w ww. ja v a 2 s . co m*/ float estimate = recommender.estimatePreference(userID, itemPref.getItemID()); Preconditions.checkState(LangUtils.isFinite(estimate)); score.increment(1.0 - estimate, itemPref.getValue()); } catch (NoSuchItemException nsie) { // continue } catch (NoSuchUserException nsue) { // continue } if (++count % 100000 == 0) { log.info("Score: {}", score); } } log.info("Score: {}", score); return new EvaluationResultImpl(score.getResult()); }
From source file:com.forerunnergames.tools.common.Strings.java
/** * Converts a multimap to a string representation. * * @param <T>/*from ww w .j a v a 2 s .c om*/ * The key type of the specified multimap. * @param <U> * The value type of the specified multimap. * @param multimap * The multimap to convert to a string, must not be null. * * @return A string representation of the multimap and its elements. */ public static <T, U> String toString(final Multimap<T, U> multimap) { Arguments.checkIsNotNull(multimap, "multimap"); final StringBuilder stringBuilder = new StringBuilder("\n"); int entryCounter = 0; for (final Map.Entry<T, U> entry : multimap.entries()) { ++entryCounter; final T entryKey = entry.getKey(); final U entryValue = entry.getValue(); stringBuilder.append(format("Entry {}:[{}, {}]\n", entryCounter, entryKey, entryValue)); } return stringBuilder.toString(); }
From source file:edu.sdsc.scigraph.services.jersey.dynamic.CypherInflector.java
Multimap<String, Object> resolveCuries(Multimap<String, Object> paramMap) { Multimap<String, Object> map = ArrayListMultimap.create(); for (Entry<String, Object> entry : paramMap.entries()) { if (entry.getValue() instanceof String) { Optional<String> iri = curieUtil.getIri((String) entry.getValue()); if (iri.isPresent()) { map.put(entry.getKey(), GraphUtil.getFragment(iri.get())); } else { map.put(entry.getKey(), entry.getValue()); }/*from w ww . j av a 2 s . co m*/ } else { map.put(entry.getKey(), entry.getValue()); } } return map; }