/** * {@inheritDoc} */ public T next() { return converter.convert(iterator.next()); }
/** * {@inheritDoc} */ public Map<String, Object> convert(F from) { Map<String, Object> map = new HashMap<String, Object>(); for (Converter<F, Map.Entry<String, Object>> projector : projectors) { Map.Entry<String, Object> entry = projector.convert(from); map.put(entry.getKey(), entry.getValue()); } return map; } }
/** * Converts all the values in the map using the given {@link Converter}. * @param map The map containing the values to be converted * @param converter The converter that specifies how each map's value must be converted * @return A Map containing the same keys of the original one and the value converted from the ones * in the corresponding entry of the map */ public static <K, F, T> Map<K, T> convertMap(Map<K, F> map, Converter<F, T> converter) { Map<K, T> converted = new HashMap<K, T>(); for (Map.Entry<K, F> entry : map.entrySet()) { converted.put(entry.getKey(), converter.convert(entry.getValue())); } return converted; }
/** * Maps the objects in the given iterable on the value extracted using the given {@link Converter}. * Actually it handles also Maps, Arrays and Iterator by collecting their values. * Note that this method accepts an Object in order to be used in conjunction with the {@link Lambda#forEach(Iterable)}. * @param iterable The iterable containing the objects to be mapped * @param converter The converter that specifies the key on which each object should be mapped * @return A map having as keys the argument value extracted from the objects in the given iterable and as values the corresponding objects */ public static <F, T> Map<T, F> map(Object iterable, Converter<F, T> converter) { Map<T, F> map = new HashMap<T, F>(); Iterator<F> i = (Iterator<F>)asIterator(iterable); while (i.hasNext()) { F item = i.next(); map.put(converter.convert(item), item); } return map; }
private int joinAndSendToQueue(List<SuspendedExecution> suspendedExecutions) { List<ExecutionMessage> messages = new ArrayList<>(); if (logger.isDebugEnabled()) logger.debug("Joining finished branches, found " + suspendedExecutions.size() + " suspended executions with all branches finished"); // nothing to do here if (suspendedExecutions.isEmpty()) return 0; for (SuspendedExecution se : suspendedExecutions) { Execution exec = joinSplit(se); messages.add(executionToStartExecutionMessage.convert(exec)); } // 3. send the suspended execution back to the queue queueDispatcherService.dispatch(messages); // 4. delete the suspended execution from the suspended table suspendedExecutionsRepository.delete(suspendedExecutions); return suspendedExecutions.size(); }
private int joinAndSendToQueue(List<SuspendedExecution> suspendedExecutions) { List<ExecutionMessage> messages = new ArrayList<>(); if (logger.isDebugEnabled()) logger.debug("Joining finished branches, found " + suspendedExecutions.size() + " suspended executions with all branches finished"); // nothing to do here if (suspendedExecutions.isEmpty()) return 0; for (SuspendedExecution se : suspendedExecutions) { Execution exec = joinSplit(se); messages.add(executionToStartExecutionMessage.convert(exec)); } // 3. send the suspended execution back to the queue queueDispatcherService.dispatch(messages); // 4. delete the suspended execution from the suspended table suspendedExecutionsRepository.delete(suspendedExecutions); return suspendedExecutions.size(); }
private static String getValue(KeyValue[] raws) { return toStringValue().convert(raws[0].getValue()); }
private static String getName(KeyValue[] raws) { return toStringValue().convert(raws[0].getQualifier()); }
private static String getValue(KeyValue[] raws) { return toStringValue().convert(raws[0].getValue()); }
private static String getName(KeyValue[] raws) { return toStringValue().convert(raws[0].getQualifier()); }