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.isotrol.impe3.pms.core.obj.PortalObject.java
public Portal start(BaseModel model, PortalsObject portals) { final Map<String, URI> ubases = Maps.newHashMap(); for (Entry<String, String> b : getActiveBases(portals).entrySet()) { try {/*from w w w . j a v a 2 s. co m*/ ubases.put(b.getKey(), new URI(b.getValue())); } catch (URISyntaxException e) { // TODO } } final Devices devicesModel = model.getDevices(); final Function<DiPObj, DeviceInPortal> u2d = new Function<DiPObj, DeviceInPortal>() { public DeviceInPortal apply(DiPObj from) { final Device d = devicesModel.get(from.getDeviceId()); return DeviceInPortal.of(d, from.getName(), from.getUse()); } }; final Device defaultDevice = devicesModel.get(devices.get().deviceId); Set<DeviceInPortal> dm = ImmutableSet.copyOf(Iterables.transform(devices.get().devices.values(), u2d)); Portal.Builder b = Portal.builder().setId(getId()).setMode(model.getMode()).setDevice(defaultDevice) .setName(name.getDisplayName()).setContentTypes(model.getContentTypes()) .setCategories(model.getCategories()).setBases(ubases).setProperties(getActiveProperties(portals)) .setUncategorized(isUncategorized(portals)).setDue(isDue(portals)) .setSetFilters(Maps.transformValues(getSetFilters(), SetFilterValue.TYPE)).setDevices(dm) .setSessionCSRF(isSessionCSRF(portals)); // Locales if (defaultLocale != null) { Set<Locale> locs = Sets.newHashSet(defaultLocale); for (String sl : locales.get().keySet()) { locs.add(Locales.fromString(sl)); } b.setDefaultLocale(defaultLocale).setLocales(locs); } // Done return b.get(); }
From source file:com.b2international.snowowl.snomed.datastore.request.DescriptionRequestHelper.java
private Map<String, SnomedDescription> extractFirst( Multimap<String, SnomedDescription> descriptionsByConceptId) { Map<String, SnomedDescription> uniqueMap = Maps.transformValues(descriptionsByConceptId.asMap(), values -> Iterables.getFirst(values, null)); return ImmutableMap.copyOf(Maps.filterValues(uniqueMap, Predicates.notNull())); }
From source file:com.cloudera.director.aws.ec2.EphemeralDeviceMappings.java
/** * Gets a test instance of this class that uses only the given mapping. * * @param counts map of instance types to counts * @param launcherLocalizationContext the parent launcher localization context * @return new mapping object/* w w w. ja va2s.co m*/ */ public static EphemeralDeviceMappings getTestInstance(Map<String, Integer> counts, LocalizationContext launcherLocalizationContext) { Map<String, String> propertyMap = Maps.transformValues(counts, Functions.toStringFunction()); PropertyResolver ephemeralDeviceMappingsResolver = PropertyResolvers.newMapPropertyResolver(propertyMap); File tempDir = Files.createTempDir(); tempDir.deleteOnExit(); EphemeralDeviceMappingsConfigProperties ephemeralDeviceMappingsConfigProperties = new EphemeralDeviceMappingsConfigProperties( new SimpleConfiguration(), tempDir, launcherLocalizationContext); return new EphemeralDeviceMappings(ephemeralDeviceMappingsConfigProperties, ephemeralDeviceMappingsResolver); }
From source file:google.registry.model.common.TimedTransitionProperty.java
/** Returns the map of DateTime to value that is the "natural" representation of this property. */ public ImmutableSortedMap<DateTime, V> toValueMap() { return ImmutableSortedMap.copyOfSorted(Maps.transformValues(backingMap, new Function<T, V>() { @Override//from w w w .j a va 2 s . c o m public V apply(T timedTransition) { return timedTransition.getValue(); } })); }
From source file:ninja.leaping.permissionsex.backend.memory.MemorySubjectData.java
@Override public Map<Set<Entry<String, String>>, Integer> getAllDefaultValues() { return Maps.filterValues( Maps.transformValues(contexts, dataEntry -> dataEntry == null ? null : dataEntry.defaultValue), v -> v != null);//from www . j a v a2 s . co m }
From source file:com.palantir.atlasdb.keyvalue.rdbms.PostgresKeyValueService.java
@Override public void put(final String tableName, final Map<Cell, byte[]> values, final long timestamp) throws KeyAlreadyExistsException { try {/*w w w . ja va2 s . com*/ batch(values.entrySet(), new Function<Collection<Entry<Cell, byte[]>>, Void>() { @Override @Nullable public Void apply(@Nullable final Collection<Entry<Cell, byte[]>> input) { getDbi().withHandle(new HandleCallback<Void>() { @Override public Void withHandle(Handle handle) throws Exception { deleteInternalInTransaction(tableName, Maps.transformValues(values, Functions.constant(timestamp)).entrySet(), handle); putInternalInTransaction(tableName, input, timestamp, handle); return null; } }); return null; } }); } catch (RuntimeException e) { if (AtlasSqlUtils.isKeyAlreadyExistsException(e)) { throw new KeyAlreadyExistsException("Unique constraint violation", e); } throw e; } }
From source file:ninja.leaping.permissionsex.backend.memory.MemoryOptionSubjectData.java
@Override public ImmutableOptionSubjectData clearParents() { if (this.contexts.isEmpty()) { return this; }// www. j a v a 2 s . c o m Map<Set<Entry<String, String>>, DataEntry> newValue = Maps.transformValues(this.contexts, new Function<DataEntry, DataEntry>() { @Nullable @Override public DataEntry apply(@Nullable DataEntry dataEntry) { return dataEntry == null ? null : dataEntry.withoutParents(); } }); return newData(newValue); }
From source file:org.apache.fluo.recipes.types.TypedSnapshotBase.java
@SuppressWarnings({ "unchecked" }) private Map<Column, Value> wrap(Map<Column, Bytes> map) { Map<Column, Value> ret = Maps.transformValues(map, input -> new Value(input)); return Collections.unmodifiableMap(DefaultedMap.decorate(ret, new Value((Bytes) null))); }
From source file:org.apache.fluo.recipes.core.types.TypedSnapshotBase.java
@SuppressWarnings({ "unchecked" }) private Map<Column, Value> wrap(Map<Column, Bytes> map) { Map<Column, Value> ret = Maps.transformValues(map, Value::new); return Collections.unmodifiableMap(DefaultedMap.decorate(ret, new Value((Bytes) null))); }
From source file:com.proofpoint.http.client.MediaType.java
private Map<String, ImmutableMultiset<String>> parametersAsMap() { return Maps.transformValues(parameters.asMap(), new Function<Collection<String>, ImmutableMultiset<String>>() { @Override/*from w w w . j a v a 2 s . c o m*/ public ImmutableMultiset<String> apply(Collection<String> input) { return ImmutableMultiset.copyOf(input); } }); }