/** * Process the collection of elements. * * @param collection * Collection that should be aggregated. */ public void processCollection(Collection<E> collection) { for (E element : collection) { processElement(element); } }
/** * Process the list of elements starting from the fromIndex (inclusive) to toIndex (exclusive). * * @param list * List of elements. * @param fromIndex * Starting index. * @param toIndex * Ending index. */ public void processList(List<E> list, int fromIndex, int toIndex) { int size = list.size(); if ((fromIndex < 0) || (fromIndex >= size)) { throw new IllegalArgumentException("Starting index " + fromIndex + " is not valid for given list of size " + size); } if ((toIndex < fromIndex) || (toIndex > size)) { throw new IllegalArgumentException("Ending index " + toIndex + " is not valid for given list of size " + size + " and starting index " + fromIndex); } for (int i = fromIndex; i < toIndex; i++) { E element = list.get(i); processElement(element); } }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void processData(DefaultData defaultData, Map<?, ?> kryoPreferences) { Long key = Long.valueOf(defaultData.getPlatformIdent()); AggregationPerformer<E> aggregationPerformer = aggregationPerformerMap.get(key); if (null == aggregationPerformer) { aggregationPerformer = aggregationPerformerMap.putIfAbsent(key, new AggregationPerformer<>(aggregator)); if (null == aggregationPerformer) { aggregationPerformer = aggregationPerformerMap.get(key); } } // deal with no saving of the invocation affiliation for cached views as well if (Boolean.FALSE.equals(kryoPreferences.get(KryoSerializationPreferences.WRITE_INVOCATION_AFFILIATION_DATA)) && (defaultData instanceof InvocationAwareData)) { InvocationAwareData invocationAwareData = (InvocationAwareData) defaultData; Map<Long, MutableInt> temp = invocationAwareData.getInvocationsParentsIdMap(); invocationAwareData.setInvocationsParentsIdMap(Collections.<Long, MutableInt> emptyMap()); aggregationPerformer.processElement((E) defaultData); invocationAwareData.setInvocationsParentsIdMap(temp); } else { aggregationPerformer.processElement((E) defaultData); } }