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:ninja.leaping.permissionsex.sponge.PEXSubjectData.java
@Override public Map<Set<Context>, Map<String, Boolean>> getAllPermissions() { return Maps.transformValues(tKeys(data.get().getAllPermissions()), map -> Maps.transformValues(map, i -> i > 0)); }
From source file:org.apache.brooklyn.util.core.config.ResolvingConfigBag.java
@Override public Map<String, Object> getAllConfig() { // Lazily transform copy of map return Maps.transformValues(super.getAllConfig(), getTransformer()); }
From source file:org.apache.aurora.scheduler.periodic.GcExecutorLauncher.java
@Override public Optional<TaskInfo> createTask(Offer offer) { if (!settings.getGcExecutorPath().isPresent() || !Resources.from(offer).greaterThanOrEqual(TOTAL_GC_EXECUTOR_RESOURCES) || isAlive(offer.getHostname())) { return Optional.absent(); }/*from w ww. j a v a 2 s .c o m*/ Set<IScheduledTask> tasksOnHost = Storage.Util.weaklyConsistentFetchTasks(storage, Query.slaveScoped(offer.getHostname())); AdjustRetainedTasks message = new AdjustRetainedTasks() .setRetainedTasks(Maps.transformValues(Tasks.mapById(tasksOnHost), Tasks.GET_STATUS)); byte[] data; try { data = ThriftBinaryCodec.encode(message); } catch (CodingException e) { LOG.severe("Failed to encode retained tasks message: " + message); return Optional.absent(); } tasksCreated.incrementAndGet(); pulses.put(offer.getHostname(), clock.nowMillis() + settings.getDelayMs()); ExecutorInfo.Builder executor = ExecutorInfo.newBuilder() .setExecutorId(ExecutorID.newBuilder().setValue(EXECUTOR_NAME)).setName(EXECUTOR_NAME) .setSource(offer.getHostname()).addAllResources(GC_EXECUTOR_RESOURCES.toResourceList()) .setCommand(CommandUtil.create(settings.getGcExecutorPath().get())); return Optional.of(TaskInfo.newBuilder().setName("system-gc") .setTaskId(TaskID.newBuilder().setValue(SYSTEM_TASK_PREFIX + UUID.randomUUID().toString())) .setSlaveId(offer.getSlaveId()).setData(ByteString.copyFrom(data)).setExecutor(executor) .addAllResources(EPSILON.toResourceList()).build()); }
From source file:org.peletomi.vax.impl.StringArrayExtractorFrontEnd.java
@Override public Map<String, String[]> getExtracted() { final Map<String, LinkedList<String>> result = new HashMap<String, LinkedList<String>>(); for (final ImmutableList<String> keys : values.keySet()) { String key;/*from w ww . j a v a 2 s . co m*/ if (qualified) { key = Joiner.on(keySeparator).join(keys); } else { key = Iterables.getLast(keys); } if (!result.containsKey(key)) { result.put(key, new LinkedList<String>()); } result.put(key, values.get(keys)); } return Maps.transformValues(result, TO_ARRAY); }
From source file:de.metas.ui.web.window.model.HighVolumeReadWriteIncludedDocumentsCollection.java
/** copy constructor */ private HighVolumeReadWriteIncludedDocumentsCollection( @NonNull final HighVolumeReadWriteIncludedDocumentsCollection from, @NonNull final Document parentDocumentCopy, @NonNull final CopyMode copyMode) { parentDocument = parentDocumentCopy; parentDocumentPath = from.parentDocumentPath; detailId = from.detailId;//w w w.ja v a2 s . co m entityDescriptor = from.entityDescriptor; _documentsWithChanges = new LinkedHashMap<>(Maps.transformValues(from._documentsWithChanges, includedDocumentOrig -> includedDocumentOrig.copy(parentDocumentCopy, copyMode))); actions = from.actions.copy(); parentReadonly = from.parentReadonly; staled = from.staled; }
From source file:com.twitter.aurora.scheduler.periodic.GcExecutorLauncher.java
@Override public Optional<TaskInfo> createTask(Offer offer) { if (!gcExecutorPath.isPresent() || !Resources.from(offer).greaterThanOrEqual(TOTAL_GC_EXECUTOR_RESOURCES) || pulseMonitor.isAlive(offer.getHostname())) { return Optional.absent(); }/*from w w w . ja v a2 s. c o m*/ Set<IScheduledTask> tasksOnHost = Storage.Util.weaklyConsistentFetchTasks(storage, Query.slaveScoped(offer.getHostname())); AdjustRetainedTasks message = new AdjustRetainedTasks() .setRetainedTasks(Maps.transformValues(Tasks.mapById(tasksOnHost), Tasks.GET_STATUS)); byte[] data; try { data = ThriftBinaryCodec.encode(message); } catch (CodingException e) { LOG.severe("Failed to encode retained tasks message: " + message); return Optional.absent(); } pulseMonitor.pulse(offer.getHostname()); ExecutorInfo.Builder executor = ExecutorInfo.newBuilder() .setExecutorId(ExecutorID.newBuilder().setValue(EXECUTOR_NAME)).setName(EXECUTOR_NAME) .setSource(offer.getHostname()).addAllResources(GC_EXECUTOR_RESOURCES.toResourceList()) .setCommand(CommandUtil.create(gcExecutorPath.get())); return Optional.of(TaskInfo.newBuilder().setName("system-gc") .setTaskId(TaskID.newBuilder().setValue(SYSTEM_TASK_PREFIX + UUID.randomUUID().toString())) .setSlaveId(offer.getSlaveId()).setData(ByteString.copyFrom(data)).setExecutor(executor) .addAllResources(EPSILON.toResourceList()).build()); }
From source file:io.wcm.config.core.management.impl.override.ParameterOverrideInfoLookup.java
/** * Make all maps and sets immutable./*w ww . ja v a 2 s . c o m*/ */ public void seal() { lockedParameterNamesSet = ImmutableSet.copyOf(lockedParameterNamesSet); lockedParameterNamesScopeMap = ImmutableMap.copyOf( Maps.transformValues(lockedParameterNamesScopeMap, new Function<Set<String>, Set<String>>() { @Override public Set<String> apply(Set<String> input) { return ImmutableSet.copyOf(input); } })); sealed = true; }
From source file:org.apache.aurora.scheduler.updater.JobDiff.java
private static JobDiff computeUnscoped(Map<Integer, ITaskConfig> currentState, IJobKey job, Map<Integer, ITaskConfig> proposedState) { requireNonNull(job);//from w w w. jav a 2 s. c om requireNonNull(proposedState); MapDifference<Integer, ITaskConfig> diff = Maps.difference(currentState, proposedState); Map<Integer, ITaskConfig> removedInstances = ImmutableMap.<Integer, ITaskConfig>builder() .putAll(diff.entriesOnlyOnLeft()) .putAll(Maps.transformValues(diff.entriesDiffering(), JobDiff.leftValue())).build(); Set<Integer> addedInstances = ImmutableSet.<Integer>builder().addAll(diff.entriesOnlyOnRight().keySet()) .addAll(diff.entriesDiffering().keySet()).build(); return new JobDiff(removedInstances, addedInstances, ImmutableMap.copyOf(diff.entriesInCommon())); }
From source file:co.cask.cdap.app.runtime.spark.distributed.SparkExecutionClient.java
/** * Writes the workflow tokens modified by this program to the given URL connection. */// ww w.j a va 2 s . c om private void writeWorkflowToken(@Nullable BasicWorkflowToken workflowToken, HttpURLConnection urlConn) throws IOException { try (Writer writer = new OutputStreamWriter(urlConn.getOutputStream(), Charsets.UTF_8)) { if (workflowToken != null) { GSON.toJson( Maps.transformValues(workflowToken.getAllFromCurrentNode(), Functions.toStringFunction()), TOKEN_TYPE, writer); } } }
From source file:com.isotrol.impe3.pms.core.obj.PortalObject.java
public static Map<String, String> toNullName(Map<String, String> map) { return Maps.transformValues(map, new Function<String, String>() { public String apply(String from) { return from != null ? from : NULL_NAME; }//from w ww. j ava 2 s .c om }); }