FieldUpdate(Field field, ValueUpdate valueUpd) { this(field); addValueUpdate(valueUpd); }
/** * Adds a list of value updates to the list of value updates. * * @param valueUpdates a list containing the value updates to add * @return a reference to itself * @throws IllegalArgumentException if the data type of the value update is not equal to the data type of this field */ public FieldUpdate addValueUpdates(List<ValueUpdate> valueUpdates) { for (ValueUpdate vupd : valueUpdates) { addValueUpdate(vupd); } return this; }
if ("increment".equals(type)) { fu.addValueUpdate(ValueUpdate.createIncrement(key, by)); } if ("decrement".equals(type)) { fu.addValueUpdate(ValueUpdate.createDecrement(key, by)); } if ("multiply".equals(type)) { fu.addValueUpdate(ValueUpdate.createMultiply(key, by)); } if ("divide".equals(type)) { fu.addValueUpdate(ValueUpdate.createDivide(key, by)); } } else { if ("increment".equals(type)) { fu.addValueUpdate(ValueUpdate.createIncrement(by)); } if ("decrement".equals(type)) { fu.addValueUpdate(ValueUpdate.createDecrement(by)); } if ("multiply".equals(type)) { fu.addValueUpdate(ValueUpdate.createMultiply(by)); } if ("divide".equals(type)) { fu.addValueUpdate(ValueUpdate.createDivide(by)); }
private void addFieldUpdates(DocumentUpdate update, TokenBuffer buffer, String fieldName) { Field field = update.getType().getField(fieldName); int localNesting = buffer.nesting(); FieldUpdate fieldUpdate = FieldUpdate.create(field); buffer.next(); while (localNesting <= buffer.nesting()) { switch (buffer.currentName()) { case UPDATE_REMOVE: createRemoves(buffer, field, fieldUpdate); break; case UPDATE_ADD: createAdds(buffer, field, fieldUpdate); break; case UPDATE_MATCH: fieldUpdate.addValueUpdate(createMapUpdate(buffer, field)); break; case UPDATE_MODIFY: fieldUpdate.addValueUpdate(createModifyUpdate(buffer, field)); break; default: String action = buffer.currentName(); fieldUpdate.addValueUpdate(readSingleUpdate(buffer, field.getDataType(), action)); } buffer.next(); } update.addFieldUpdate(fieldUpdate); }
public void read(FieldUpdate fieldUpdate) { int fieldId = getInt(null); Field field = fieldUpdate.getDocumentType().getField(fieldId, fieldUpdate.getSerializationVersion()); if (field == null) { throw new DeserializationException( "Cannot deserialize FieldUpdate, field fieldId " + fieldId + " not found in " + fieldUpdate.getDocumentType()); } fieldUpdate.setField(field); int size = getInt(null); for (int i = 0; i < size; i++) { if (field.getDataType() instanceof CollectionDataType) { CollectionDataType collType = (CollectionDataType) field.getDataType(); fieldUpdate.addValueUpdate(getValueUpdate(collType, collType.getNestedType())); } else { fieldUpdate.addValueUpdate(getValueUpdate(field.getDataType(), null)); } } }
public void read(FieldUpdate fieldUpdate) { int fieldId = getInt(null); Field field = fieldUpdate.getDocumentType().getField(fieldId, fieldUpdate.getSerializationVersion()); if (field == null) { throw new DeserializationException( "Cannot deserialize FieldUpdate, field fieldId " + fieldId + " not found in " + fieldUpdate.getDocumentType()); } fieldUpdate.setField(field); int size = getInt(null); for (int i = 0; i < size; i++) { if (field.getDataType() instanceof CollectionDataType) { CollectionDataType collType = (CollectionDataType) field.getDataType(); fieldUpdate.addValueUpdate(getValueUpdate(collType, collType.getNestedType())); } else { fieldUpdate.addValueUpdate(getValueUpdate(field.getDataType(), null)); } } }
fieldUpdate.addValueUpdate(AssignValueUpdate.createAssign(new IntegerFieldValue(42))); update.addFieldUpdate(fieldUpdate);