private AssignFieldPathUpdate readArithmeticFieldPathUpdate( DocumentType documentType, String fieldPath, TokenBuffer buffer, String fieldPathOperation) { AssignFieldPathUpdate fieldPathUpdate = new AssignFieldPathUpdate(documentType, fieldPath); String arithmeticSign = SingleValueReader.UPDATE_OPERATION_TO_ARITHMETIC_SIGN.get(fieldPathOperation); double value = Double.valueOf(buffer.currentText()); String expression = String.format("$value %s %s", arithmeticSign, value); fieldPathUpdate.setExpression(expression); return fieldPathUpdate; }
public static FieldPathUpdate create(Type type, DocumentType docType, DocumentUpdateReader reader) { switch (type) { case ASSIGN: return new AssignFieldPathUpdate(docType, reader); case ADD: return new AddFieldPathUpdate(docType, reader); case REMOVE: return new RemoveFieldPathUpdate(docType, reader); } throw new IllegalArgumentException("Field path update type '" + type + "' not supported."); }
private AssignFieldPathUpdate readAssignFieldPathUpdate(DocumentType documentType, String fieldPath, TokenBuffer buffer) { AssignFieldPathUpdate fieldPathUpdate = new AssignFieldPathUpdate(documentType, fieldPath); FieldValue fv = SingleValueReader.readSingleValue( buffer, fieldPathUpdate.getFieldPath().getResultingDataType()); fieldPathUpdate.setNewValue(fv); return fieldPathUpdate; }
if (hasFieldPath()) { if ("assign".equals(currentName)) { update.addFieldPathUpdate(new AssignFieldPathUpdate(doctype, this)); skipToEnd("assign"); } else if ("add".equals(currentName)) {
update.getOriginalWhereClause(), (Array)value)); } else if (update instanceof AssignFieldPathUpdate) { out.addFieldPathUpdate(new AssignFieldPathUpdate(update.getDocumentType(), new FieldPath(path).toString(), update.getOriginalWhereClause(), value)); } else if (update instanceof RemoveFieldPathUpdate) {