InstanceInfo.Builder applyTo(InstanceInfo.Builder instanceInfoBuilder) { return field.update(instanceInfoBuilder, value); }
InstanceInfoField<Object> field = InstanceInfoField.forName(name); if (field.getValueType().equals(Integer.class)) { value = Integer.parseInt(args[1]); } else if (field.getValueType().equals(InstanceInfo.Status.class)) { value = InstanceInfo.Status.valueOf(args[1]); } else {
private static Set<Delta<?>> diff(InstanceInfo oldInstanceInfo, InstanceInfo newInstanceInfo) { if (oldInstanceInfo == null || newInstanceInfo == null) { return null; } if (!oldInstanceInfo.getId().equals(newInstanceInfo.getId())) { return null; } Set<Delta<?>> deltas = new HashSet<Delta<?>>(); for (InstanceInfoField.Name fieldName : InstanceInfoField.Name.values()) { InstanceInfoField<Object> field = InstanceInfoField.forName(fieldName); Object oldValue = field.getValue(oldInstanceInfo); Object newValue = field.getValue(newInstanceInfo); if (!equalsNullable(oldValue, newValue)) { // there is a difference Delta<?> delta = new Delta.Builder() .withId(newInstanceInfo.getId()) .withDelta(field, newValue) .build(); deltas.add(delta); } } return deltas; }
@SuppressWarnings({"unchecked", "rawtypes"}) static DeltaDTO<?> toDeltaDTO(Delta<?> delta) { Type type = delta.getField().getValueType(); if (type instanceof Class) { Class<?> ctype = (Class<?>) type;
@SuppressWarnings("unchecked") public Delta<T> toDelta() { return (Delta<T>) new Delta.Builder() .withId(id) .withDelta(InstanceInfoField.forName(Name.forName(fieldName)), getValue()) .build(); }
protected DeltaDTO(Delta<T> delta) { this.id = delta.getId(); this.fieldName = delta.getField().getFieldName().name(); }