/** * Creates a new field update, with one encapsulated value update that increments a value. * Note that the data type must be a numeric type. * * @param field the field to increment the value of * @param increment the number to increment by * @return a FieldUpdate specifying the increment * @throws UnsupportedOperationException if the data type is non-numeric * @see ValueUpdate#createIncrement(Number) */ public static FieldUpdate createIncrement(Field field, Number increment) { return new FieldUpdate(field, ValueUpdate.createIncrement(increment)); }
/** * Creates a new field update that clears the field. This operation removes the value/field completely. * * @param field the Field to clear * @return a FieldUpdate specifying the clearing * @see com.yahoo.document.update.FieldUpdate#createClear(Field) */ public static FieldUpdate createClearField(Field field) { return new FieldUpdate(field, ValueUpdate.createClear()); }
/** * Creates a new field update, with one encapsulated value update * specifying an addition of a value to an array or a key to a weighted set (with default weight 1). * * @param field the Field to add a value to * @param value the value to add to the array, or key to add to the weighted set * @return a FieldUpdate specifying the addition * @throws IllegalArgumentException if the runtime type of newValue does not match the type required by field * @throws UnsupportedOperationException if the field type is not array or weighted set * @see com.yahoo.document.update.ValueUpdate#createAdd(FieldValue) */ public static FieldUpdate createAdd(Field field, FieldValue value) { return new FieldUpdate(field, ValueUpdate.createAdd(value)); }
/** * Creates a new field update, with one encapsulated value update that multiplies a value. * Note that the data type must be a numeric type. * * @param field the field to multiply the value of * @param factor the number to multiply by * @return a FieldUpdate specifying the multiplication * @throws UnsupportedOperationException if the data type is non-numeric * @see ValueUpdate#createMultiply(Number) */ public static FieldUpdate createMultiply(Field field, Number factor) { return new FieldUpdate(field, ValueUpdate.createMultiply(factor)); }
/** * Creates a new field update, with one encapsulated value update that divides a value. * Note that the data type must be a numeric type. * * @param field the field to divide the value of * @param divisor the number to divide by * @return a FieldUpdate specifying the division * @throws UnsupportedOperationException if the data type is non-numeric * @see ValueUpdate#createDivide(Number) */ public static FieldUpdate createDivide(Field field, Number divisor) { return new FieldUpdate(field, ValueUpdate.createDivide(divisor)); }
/** * Creates a new field update, with one encapsulated value update that decrements a value. * Note that the data type must be a numeric type. * * @param field the field to decrement the value of * @param decrement the number to decrement by * @return a FieldUpdate specifying the decrement * @throws UnsupportedOperationException if the data type is non-numeric * @see ValueUpdate#createDecrement(Number) */ public static FieldUpdate createDecrement(Field field, Number decrement) { return new FieldUpdate(field, ValueUpdate.createDecrement(decrement)); }
/** * Creates a new field update, with one encapsulated value update, * that assigns a new value, completely overwriting the previous value. Note that it is possible to pass * newValue=null to this method to remove the value completely. * * @param field the Field to assign a new value to * @param newValue the value to assign * @return a FieldUpdate specifying the assignment * @throws IllegalArgumentException if the runtime type of newValue does not match the type required by field * @see com.yahoo.document.update.ValueUpdate#createAssign(FieldValue) */ public static FieldUpdate createAssign(Field field, FieldValue newValue) { return new FieldUpdate(field, ValueUpdate.createAssign(newValue)); }
/** * Creates a new value update that clears the field fromthe document. * * @return a ValueUpdate specifying the removal */ public static ValueUpdate createClear() { return new ClearValueUpdate(); }
/** * Creates a new value update specifying the removal of a value from an array or a key/weight from a weighted set. * * @param value the value to remove from the array, or key to remove from the weighted set * @return a ValueUpdate specifying the removal * @throws IllegalArgumentException if the runtime type of newValue does not match the type required * @throws UnsupportedOperationException if the field type is not array or weighted set */ public static ValueUpdate createRemove(FieldValue value) { return new RemoveValueUpdate(value); }
/** * Creates a new value update that assigns a new value, completely overwriting * the previous value. * * @param newValue the value to assign * @return a ValueUpdate specifying the assignment * @throws IllegalArgumentException if the runtime type of newValue does not match the type required */ public static ValueUpdate createAssign(FieldValue newValue) { return new AssignValueUpdate(newValue); }
FieldUpdate(Field field, ValueUpdate valueUpd) { this(field); addValueUpdate(valueUpd); }
/** * Creates a new value update that divides a value. Note that the data type must be a numeric * type. * * @param divisor the number to divide by * @return a ValueUpdate specifying the division * @throws UnsupportedOperationException if the data type is non-numeric */ public static ValueUpdate createDivide(Number divisor) { return new ArithmeticValueUpdate(ArithmeticValueUpdate.Operator.DIV, divisor); }
/** * Creates a new, empty field update with no encapsulated value updates. Use this method to add an arbitrary * set of value updates using the FieldUpdate.addValueUpdate() method. * * @param field the Field to alter * @return a new, empty FieldUpdate * @see com.yahoo.document.update.ValueUpdate * @see FieldUpdate#addValueUpdate(ValueUpdate) */ public static FieldUpdate create(Field field) { return new FieldUpdate(field); }
public static Operation getOperation(int id) { for (Operation operation : Operation.values()) { if (operation.id == id) { return operation; } } return null; } }
public static ValueUpdateClassID getID(int id) { for (ValueUpdateClassID vucid : ValueUpdateClassID.values()) { if (vucid.id == id) { return vucid; } } return null; } }
@Override public String toString() { return super.toString() + " " + value; } }
/** * Creates a new field update, with one encapsulated value update that increments a weight in a weighted set. * * @param field the field to increment one of the weights of * @param key the key whose weight in the weighted set to increment * @param increment the number to increment by * @return a FieldUpdate specifying the increment * @throws IllegalArgumentException if key is not equal to the nested type of the weighted set * @see ValueUpdate#createIncrement(Number) * @see ValueUpdate#createMap(FieldValue, ValueUpdate) */ public static FieldUpdate createIncrement(Field field, FieldValue key, Number increment) { return new FieldUpdate(field, ValueUpdate.createIncrement(key, increment)); }
/** * Creates a new field update, with one encapsulated value update that multiplies a weight in a weighted set. * * @param field the field to multiply one of the weights of * @param key the key whose weight in the weighted set to multiply * @param factor the number to multiply by * @return a FieldUpdate specifying the multiplication * @throws IllegalArgumentException if key is not equal to the nested type of the weighted set * @see ValueUpdate#createMultiply(Number) * @see ValueUpdate#createMap(FieldValue, ValueUpdate) */ public static FieldUpdate createMultiply(Field field, FieldValue key, Number factor) { return new FieldUpdate(field, ValueUpdate.createMultiply(key, factor)); }
/** * Creates a new field update, with one encapsulated value update that divides a weight in a weighted set. * * @param field the field to divide one of the weights of * @param key the key whose weight in the weighted set to divide * @param divisor the number to divide by * @return a FieldUpdate specifying the division * @throws IllegalArgumentException if key is not equal to the nested type of the weighted set * @see ValueUpdate#createDivide(Number) * @see ValueUpdate#createMap(FieldValue, ValueUpdate) */ public static FieldUpdate createDivide(Field field, FieldValue key, Number divisor) { return new FieldUpdate(field, ValueUpdate.createDivide(key, divisor)); }
/** * Creates a new value update that decrements a value. Note that the data type must be a numeric * type. * * @param decrement the number to decrement by * @return a ValueUpdate specifying the decrement * @throws UnsupportedOperationException if the data type is non-numeric */ public static ValueUpdate createDecrement(Number decrement) { return new ArithmeticValueUpdate(ArithmeticValueUpdate.Operator.SUB, decrement); }