List of usage examples for com.google.common.collect Maps transformValues
@GwtIncompatible("NavigableMap") public static <K, V1, V2> NavigableMap<K, V2> transformValues(NavigableMap<K, V1> fromMap, Function<? super V1, V2> function)
From source file:com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.java
public static RequestTemplateModel from(final Request request) { URI url = URI.create(request.getUrl()); Map<String, QueryParameter> rawQuery = Urls.splitQuery(url); Map<String, ListOrSingle<String>> adaptedQuery = Maps.transformValues(rawQuery, TO_TEMPLATE_MODEL); Map<String, ListOrSingle<String>> adaptedHeaders = Maps.toMap(request.getAllHeaderKeys(), new Function<String, ListOrSingle<String>>() { @Override//from ww w . j a v a 2 s .c o m public ListOrSingle<String> apply(String input) { return ListOrSingle.of(request.header(input).values()); } }); Map<String, ListOrSingle<String>> adaptedCookies = Maps.transformValues(request.getCookies(), new Function<Cookie, ListOrSingle<String>>() { @Override public ListOrSingle<String> apply(Cookie input) { return ListOrSingle.of(input.getValue()); } }); UrlPath path = new UrlPath(request.getUrl()); return new RequestTemplateModel(request.getUrl(), path, adaptedQuery, adaptedHeaders, adaptedCookies, request.getBodyAsString()); }
From source file:foo.domaintest.util.QueryStringHelper.java
public static String encodeQuery(Map<String, String> params) { return Joiner.on('&').withKeyValueSeparator("=") .join(Maps.transformValues(params, new Function<String, String>() { @Override// ww w. ja va 2 s. c om public String apply(String input) { try { return URLEncoder.encode(input, UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } } })); }
From source file:com.facebook.presto.util.MapTransformer.java
public <V1> MapTransformer<K, V1> transformValues(Function<V, V1> function) { return new MapTransformer<>(Maps.transformValues(map, function)); }
From source file:pgentity.quest.SellPenguinsChecker.java
@Override public boolean isAccept(EntityContext context) { Set<String> penguinIDs = context.getCote().penguins().getAll(); Map<String, Integer> nPenguinsOK = Maps.transformValues(requires, new Function<SellPenguinRequire, Integer>() { @Override/*from ww w . j a va 2 s . c o m*/ public Integer apply(SellPenguinRequire f) { return 0; } }); for (String penguinID : penguinIDs) { Penguin penguin = Penguin.getPenguin(context.getUid(), context.getCoteID(), penguinID); if (requires.containsKey(penguin.getKind()) && penguin.getLevel() >= requires.get(penguin.getKind()).level()) { nPenguinsOK.put(penguin.getKind(), nPenguinsOK.get(penguin.getKind()) + 1); } } for (String pKind : requires.keySet()) { if (nPenguinsOK.get(pKind) < requires.get(pKind).number()) { return false; } } return true; }
From source file:com.google.api.client.discovery.types.ObjectType.java
/** * Returns the named properties and the strongly typed description of what * they will contain.// ww w . j a v a 2 s . c o m */ public Map<String, DiscoveryType> getProperties() { Map<String, Jsonschema> props = schemaNode.getProperties(); return props == null ? null : Maps.transformValues(props, schemaToDisicoveryType); }
From source file:org.jfrog.bamboo.context.IvyBuildContext.java
public static IvyBuildContext createIvyContextFromMap(Map<String, Object> map) { Map<String, String> transformed = Maps.transformValues(map, new Function<Object, String>() { @Override//from w w w . java2 s.com public String apply(Object input) { return input.toString(); } }); return new IvyBuildContext(transformed); }
From source file:com.addthis.bundle.value.ValueMap.java
@Override public default Map<String, Object> asNative() { return Maps.transformValues(this, AsNative.INSTANCE); }
From source file:uk.ac.open.kmi.iserve.discovery.ranking.impl.UsageScorer.java
@Override public Map<URI, Double> apply(Set<URI> resources) { Map<URI, Object> popObjectsMap = getNfpManager().getPropertyValueOfResources(resources, URI.create(MSM_NFP.hasPopularity.getURI()), Double.class); Map<URI, Double> result = Maps.transformValues(popObjectsMap, new Function<Object, Double>() { @Override//w ww . jav a 2 s . c om public Double apply(Object input) { Double r = (Double) input; if (r != null && r > 0) { return r / 100; } return Double.valueOf(0); } }); return result; }
From source file:com.google.devtools.build.lib.runtime.CommandNameCacheImpl.java
CommandNameCacheImpl(Map<String, BlazeCommand> commandMap) { // Note: it is important that this map is live, since the commandMap may be altered // post-creation. this.commandMap = Maps.transformValues(commandMap, new Function<BlazeCommand, Command>() { @Override//from ww w . j a v a 2 s . c o m public Command apply(BlazeCommand blazeCommand) { return blazeCommand.getClass().getAnnotation(Command.class); } }); }
From source file:com.proofpoint.discovery.store.StoreResource.java
@Inject public StoreResource(Map<String, InMemoryStore> localStores, Map<String, StoreConfig> configs) { this.localStores = ImmutableMap.copyOf(localStores); this.tombstoneMaxAges = ImmutableMap.copyOf(Maps.transformValues(configs, StoreConfig::getTombstoneMaxAge)); }