@Override public CounterDTO clone() { final CounterDTO other = new CounterDTO(); other.setId(getId()); other.setName(getName()); other.setContext(getContext()); other.setValue(getValue()); other.setValueCount(getValueCount()); return other; } }
public static void merge(final CounterDTO target, final CounterDTO toMerge) { target.setValueCount(target.getValueCount() + toMerge.getValueCount()); target.setValue(FormatUtils.formatCount(target.getValueCount())); }
/** * Creates a CounterDTO from the specified Counter. * * @param counter counter * @return dto */ public CounterDTO createCounterDto(final Counter counter) { final CounterDTO dto = new CounterDTO(); dto.setId(counter.getIdentifier()); dto.setContext(counter.getContext()); dto.setName(counter.getName()); dto.setValueCount(counter.getValue()); dto.setValue(FormatUtils.formatCount(counter.getValue())); return dto; }
public static void merge(final CountersSnapshotDTO target, final CountersSnapshotDTO toMerge) { final Map<String, CounterDTO> counters = new HashMap<>(); for (final CounterDTO counter : target.getCounters()) { counters.put(counter.getId(), counter); } for (final CounterDTO counter : toMerge.getCounters()) { final CounterDTO existing = counters.get(counter.getId()); if (existing == null) { counters.put(counter.getId(), counter); } else { merge(existing, counter); } } target.setCounters(counters.values()); }
@Override public CountersSnapshotDTO clone() { final CountersSnapshotDTO other = new CountersSnapshotDTO(); other.setGenerated(getGenerated()); final List<CounterDTO> clonedCounters = new ArrayList<>(getCounters().size()); for (final CounterDTO counterDto : getCounters()) { clonedCounters.add(counterDto.clone()); } other.setCounters(clonedCounters); return other; } }