List of usage examples for com.google.common.collect Multimap entries
Collection<Map.Entry<K, V>> entries();
From source file:foo.domaintest.http.HttpApiModule.java
@Provides @Singleton//w ww. j ava2 s . c o m @EasterEggs String provideEasterEggUrl(Multimap<String, String> params, @EasterEggs Table<String, String, String> easterEggs) { for (Entry<String, String> param : params.entries()) { String easterEggUrl = easterEggs.get(param.getKey(), param.getValue()); if (easterEggUrl != null) { return easterEggUrl; } } return null; }
From source file:org.obm.sync.client.impl.AbstractClientImpl.java
@VisibleForTesting void setPostRequestParameters(Request request, Multimap<String, String> parameters) { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); for (Entry<String, String> entry : parameters.entries()) { if (entry.getKey() != null && entry.getValue() != null) { nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); }/*from w w w .ja va 2 s . c o m*/ } request.bodyForm(nameValuePairs, Charsets.UTF_8); }
From source file:org.jclouds.scriptbuilder.domain.UnzipHttpResponseIntoDirectory.java
/** * // w w w .ja v a2s. c om * * @param method * http method: ex GET * @param endpoint * uri corresponding to the request * @param headers * request headers to send */ public UnzipHttpResponseIntoDirectory(String method, URI endpoint, Multimap<String, String> headers, String dir) { super(format( "({md} %s &&{cd} %s &&curl -X -L %s -s --retry 20 %s %s >extract.zip && unzip -o -qq extract.zip&& rm extract.zip)\n", dir, dir, method, Joiner.on(' ').join(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())); }
From source file:org.jclouds.s3.filters.RequestAuthorizeSignature.java
@VisibleForTesting void appendHttpHeaders(HttpRequest request, SortedSetMultimap<String, String> canonicalizedHeaders) { Multimap<String, String> headers = request.getHeaders(); for (Entry<String, String> header : headers.entries()) { if (header.getKey() == null) continue; String key = header.getKey().toString().toLowerCase(Locale.getDefault()); // Ignore any headers that are not particularly interesting. if (key.equalsIgnoreCase(HttpHeaders.CONTENT_TYPE) || key.equalsIgnoreCase("Content-MD5") || key.equalsIgnoreCase(HttpHeaders.DATE) || key.startsWith("x-" + headerTag + "-")) { canonicalizedHeaders.put(key, header.getValue()); }//from w w w . j a v a2 s. com } }
From source file:org.jclouds.s3.filters.RequestAuthorizeSignatureV2.java
@VisibleForTesting void appendHttpHeaders(HttpRequest request, SortedSetMultimap<String, String> canonicalizedHeaders) { Multimap<String, String> headers = request.getHeaders(); for (Map.Entry<String, String> header : headers.entries()) { if (header.getKey() == null) { continue; }//from www .j a v a2 s.com String key = header.getKey().toString().toLowerCase(Locale.getDefault()); // Ignore any headers that are not particularly interesting. if (key.equalsIgnoreCase(HttpHeaders.CONTENT_TYPE) || key.equalsIgnoreCase("Content-MD5") || key.equalsIgnoreCase(HttpHeaders.DATE) || key.startsWith("x-" + headerTag + "-")) { canonicalizedHeaders.put(key, header.getValue()); } } }
From source file:ezbake.discovery.stethoscope.server.StethoscopeServiceHandler.java
@Override public TProcessor getThriftProcessor() { this.configuration = new EzProperties(getConfigurationProperties(), true); this.serviceDiscoveryClient = new ServiceDiscoveryClient(configuration); int expireMinutes = configuration.getInteger(STETHOSCOPE_SERVICE_WRITE_EXPIRE_TIME, 15); boolean shouldRemoveEntriesFromZookeeper = configuration .getBoolean(STETHOSCOPE_ACTUALLY_REMOVE_FROM_ZOOKEEPER, false); logger.info("Stethoscope will wait {} minutes before timing something out after write", expireMinutes); Multimap<String, String> servicesToIgnore = getServicesToIgnore( configuration.getProperty(STETHOSCOPE_SERVICES_TO_IGNORE, "")); for (Map.Entry<String, String> entry : servicesToIgnore.entries()) { logger.info("Application: {}, Service: {} will NOT be removed from zookeeper", entry.getKey(), entry.getValue());// w w w . j a v a2 s . co m } if (shouldRemoveEntriesFromZookeeper) { logger.info("Stethoscope will remove entries from zookeeper"); } else { logger.info("Stethoscope will NOT remove entries from zookeeper"); } this.serviceCache = CacheBuilder.newBuilder().expireAfterWrite(expireMinutes, TimeUnit.MINUTES) .removalListener(new StethoscopeCacheRemovalListener(serviceDiscoveryClient, shouldRemoveEntriesFromZookeeper, servicesToIgnore)) .build(); this.scheduler = Executors.newScheduledThreadPool(1); int cleanupMinutes = configuration.getInteger(STETHOSCOPE_SERVICE_CLEANUP_TIME, 10); logger.info("Stethoscope will wait {} minutes before running the clean up thread!", cleanupMinutes); scheduler.scheduleAtFixedRate(new CacheMaintenanceRunnable(), 0, cleanupMinutes, TimeUnit.MINUTES); populateCacheFromZookeeper(); return new StethoscopeService.Processor(this); }
From source file:com.linecorp.armeria.common.MediaType.java
private static MediaType create(String type, String subtype, Multimap<String, String> parameters) { checkNotNull(type);//from w ww .ja v a2 s .co m checkNotNull(subtype); checkNotNull(parameters); String normalizedType = normalizeToken(type); String normalizedSubtype = normalizeToken(subtype); checkArgument(!WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype), "A wildcard type cannot be used with a non-wildcard subtype"); Builder<String, String> builder = ImmutableListMultimap.builder(); for (Entry<String, String> entry : parameters.entries()) { String attribute = normalizeToken(entry.getKey()); builder.put(attribute, normalizeParameterValue(attribute, entry.getValue())); } MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build()); // Return one of the constants if the media type is a known type. return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType); }
From source file:org.sosy_lab.cpachecker.cpa.constraints.refiner.precision.ConstraintBasedConstraintsPrecision.java
private void addNewFunctionConstraints(Multimap<String, Constraint> pMapToAddTo, Multimap<String, Constraint> pNewConstraints) { for (Entry<String, Constraint> entry : pNewConstraints.entries()) { String function = entry.getKey(); Constraint constraint = entry.getValue(); if (!constraintWithSameMeaningExists(function, constraint, pMapToAddTo)) { pMapToAddTo.put(function, constraint); }//from ww w . ja v a2 s.co m } }
From source file:org.sosy_lab.cpachecker.cpa.constraints.refiner.precision.ConstraintBasedConstraintsPrecision.java
private void addNewLocalConstraints(Multimap<CFANode, Constraint> pMapToAddTo, Multimap<CFANode, Constraint> pNewConstraints) { for (Entry<CFANode, Constraint> entry : pNewConstraints.entries()) { CFANode loc = entry.getKey();//from w ww . j ava 2 s.co m Constraint constraint = entry.getValue(); if (!constraintWithSameMeaningExists(loc, constraint, pMapToAddTo)) { pMapToAddTo.put(loc, constraint); } } }
From source file:org.apache.whirr.service.jclouds.SaveHttpResponseTo.java
public SaveHttpResponseTo(String dir, String file, String method, URI endpoint, Multimap<String, String> headers) { super(String.format( "({md} %s && {cd} %s && [ ! -f %s ] && " + "curl -C - -s -q -L --connect-timeout 10 --max-time 600 -X %s -s --retry 20 %s %s >%s)\n", dir, dir, file, method, Joiner.on(' ').join( Iterables.transform(headers.entries(), new Function<Map.Entry<String, String>, String>() { @Override public String apply(Map.Entry<String, String> from) { return String.format("-H \"%s: %s\"", from.getKey(), from.getValue()); }//from w w w . j av a 2s.c o m })), endpoint.toASCIIString(), file)); }