@Test(expected = IllegalArgumentException.class) public void merge_olderState_throwsException() { TypedValues values1 = TypedValues.builder() .source("no_source") .timestamp(90) .values(new HashMap<>()) .build(); values.merge(values1); }
public TypedValues merge(TypedValues typedValues) { Preconditions.checkArgument(source.equals(typedValues.getSource()), "Both values have to come from the same source!"); Preconditions.checkArgument(typedValues.getTimestamp() >= timestamp, "You try to merge a typed value that is older than the current state"); Map<String, Value> newValues = new HashMap<>(); newValues.putAll(values); newValues.putAll(typedValues.getValues()); return new TypedValues(this.source, typedValues.getTimestamp(), newValues); }
TypedValues implements MRecord, Serializable { public TypedValues merge(TypedValues typedValues) { Preconditions.checkArgument(source.equals(typedValues.getSource()), "Both values have to come from the same source!"); Preconditions.checkArgument(typedValues.getTimestamp() >= timestamp, "You try to merge a typed value that is older than the current state"); Map<String, Value> newValues = new HashMap<>(); newValues.putAll(values); newValues.putAll(typedValues.getValues()); return new TypedValues(this.source, typedValues.getTimestamp(), newValues); } }
TypedValues implements MRecord, Serializable { public TypedValues merge(TypedValues typedValues) { Preconditions.checkArgument(source.equals(typedValues.getSource()), "Both values have to come from the same source!"); Preconditions.checkArgument(typedValues.getTimestamp() >= timestamp, "You try to merge a typed value that is older than the current state"); Map<String, Value> newValues = new HashMap<>(); newValues.putAll(values); newValues.putAll(typedValues.getValues()); return new TypedValues(this.source, typedValues.getTimestamp(), newValues); } TypedValues(String source, long timestamp, Map<String, Value> values); }
TypedValues implements MRecord, Serializable { public TypedValues merge(TypedValues typedValues) { Preconditions.checkArgument(source.equals(typedValues.getSource()), "Both values have to come from the same source!"); Preconditions.checkArgument(typedValues.getTimestamp() >= timestamp, "You try to merge a typed value that is older than the current state"); Map<String, Value> newValues = new HashMap<>(); newValues.putAll(values); newValues.putAll(typedValues.getValues()); return new TypedValues(this.source, typedValues.getTimestamp(), newValues); } TypedValues(String source, long timestamp, Map<String, Value> values); @Override Double getDouble(String channel); @Override Long getLong(String channel); @Override @SuppressWarnings("squid:S2447") // null should not be returned, in this case it is necessary Boolean getBoolean(String channel); @Override Date getDate(String channel); @Override String getString(String channel); @Override Value getValue(String channel); @Override @Deprecated @SuppressWarnings("squid:S1133") // suppress deprecated warning Object get(String channel); @Override Collection<String> getChannels(); TypedValues merge(TypedValues typedValues); }
TypedValues implements MRecord, Serializable { public TypedValues merge(TypedValues typedValues) { Preconditions.checkArgument(source.equals(typedValues.getSource()), "Both values have to come from the same source!"); Preconditions.checkArgument(typedValues.getTimestamp() >= timestamp, "You try to merge a typed value that is older than the current state"); Map<String, Value> newValues = new HashMap<>(); newValues.putAll(values); newValues.putAll(typedValues.getValues()); return new TypedValues(this.source, typedValues.getTimestamp(), newValues); } TypedValues(String source, long timestamp, Map<String, Value> values); @Override Double getDouble(String channel); @Override Long getLong(String channel); @Override @SuppressWarnings("squid:S2447") // null should not be returned, in this case it is necessary Boolean getBoolean(String channel); @Override Date getDate(String channel); @Override String getString(String channel); @Override Value getValue(String channel); @Override @Deprecated @SuppressWarnings("squid:S1133") // suppress deprecated warning Object get(String channel); @Override Collection<String> getChannels(); TypedValues merge(TypedValues typedValues);  }