Class ValueUpdate<T extends FieldValue>

    • Method Detail

      • getValueUpdateClassID

        public ValueUpdate.ValueUpdateClassID getValueUpdateClassID()
        Returns the valueUpdateClassID of this value update.
        Returns:
        the valueUpdateClassID of this ValueUpdate
      • checkCompatibility

        protected abstract void checkCompatibility​(DataType fieldType)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • createAdd

        public static ValueUpdate createAdd​(FieldValue value)
        Creates a new value update specifying an addition of a value to an array or a key to a weighted set (with default weight 1).
        Parameters:
        value - the value to add to the array, or key to add to the weighted set
        Returns:
        a ValueUpdate specifying the addition
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of newValue does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not array or weighted set
      • createAdd

        public static ValueUpdate createAdd​(FieldValue key,
                                            java.lang.Integer weight)
        Creates a new value update specifying an addition of a key (with a specified weight) to a weighted set. If this method is used on an array data type, the weight will be omitted.
        Parameters:
        key - the key to add
        weight - the weight to associate with the given key
        Returns:
        a ValueUpdate specifying the addition
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of key does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not array or weighted set
      • createAddAll

        public static java.util.List<ValueUpdate> createAddAll​(java.util.List<? extends FieldValue> values)
        Creates a new value update specifying an addition of all values in a given list to an array. If this method is used on a weighted set data type, the default weights will be 1. Note that this method is just a convenience method, it simply iterates through the list and creates value updates by calling createAdd() for each element.
        Parameters:
        values - a List containing the values to add
        Returns:
        a List of ValueUpdates specifying the addition
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of values does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not array or weighted set
        See Also:
        createAdd(FieldValue)
      • createAddAll

        public static java.util.List<ValueUpdate> createAddAll​(WeightedSet<? extends FieldValue> set)
        Creates a new value update specifying an addition of all key/weight pairs in a weighted set to a weighted set. If this method is used on an array data type, the weights will be omitted. Note that this method is just a convenience method, it simply iterates through the set and creates value updates by calling createAdd() for each element.
        Parameters:
        set - a WeightedSet containing the key/weight pairs to add
        Returns:
        a ValueUpdate specifying the addition
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of values does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not weighted set or array
        See Also:
        createAdd(FieldValue, Integer)
      • createIncrement

        public static ValueUpdate createIncrement​(java.lang.Number increment)
        Creates a new value update that increments a value. Note that the data type must be a numeric type.
        Parameters:
        increment - the number to increment by
        Returns:
        a ValueUpdate specifying the increment
        Throws:
        java.lang.UnsupportedOperationException - if the data type is non-numeric
      • createIncrement

        public static ValueUpdate createIncrement​(FieldValue key,
                                                  java.lang.Number increment)
        Creates a new value update that increments a weight in a weighted set. Note that this method is just a convenience method, it simply creates an increment value update by calling createIncrement() and then creates a map value update by calling createMap() with the key and the increment value update as parameters.
        Parameters:
        key - the key whose weight in the weighted set to increment
        increment - the number to increment by
        Returns:
        a ValueUpdate specifying the increment
        See Also:
        createIncrement(Number), createMap(FieldValue, ValueUpdate)
      • createDecrement

        public static ValueUpdate createDecrement​(java.lang.Number decrement)
        Creates a new value update that decrements a value. Note that the data type must be a numeric type.
        Parameters:
        decrement - the number to decrement by
        Returns:
        a ValueUpdate specifying the decrement
        Throws:
        java.lang.UnsupportedOperationException - if the data type is non-numeric
      • createDecrement

        public static ValueUpdate createDecrement​(FieldValue key,
                                                  java.lang.Number decrement)
        Creates a new value update that decrements a weight in a weighted set. Note that this method is just a convenience method, it simply creates a decrement value update by calling createDecrement() and then creates a map value update by calling createMap() with the key and the decrement value update as parameters.
        Parameters:
        key - the key whose weight in the weighted set to decrement
        decrement - the number to decrement by
        Returns:
        a ValueUpdate specifying the decrement
        See Also:
        createDecrement(Number), createMap(FieldValue, ValueUpdate)
      • createMultiply

        public static ValueUpdate createMultiply​(java.lang.Number factor)
        Creates a new value update that multiplies a value. Note that the data type must be a numeric type.
        Parameters:
        factor - the number to multiply by
        Returns:
        a ValueUpdate specifying the multiplication
        Throws:
        java.lang.UnsupportedOperationException - if the data type is non-numeric
      • createMultiply

        public static ValueUpdate createMultiply​(FieldValue key,
                                                 java.lang.Number factor)
        Creates a new value update that multiplies a weight in a weighted set. Note that this method is just a convenience method, it simply creates a multiply value update by calling createMultiply() and then creates a map value update by calling createMap() with the key and the multiply value update as parameters.
        Parameters:
        key - the key whose weight in the weighted set to multiply
        factor - the number to multiply by
        Returns:
        a ValueUpdate specifying the multiplication
        See Also:
        createMultiply(Number), createMap(FieldValue, ValueUpdate)
      • createDivide

        public static ValueUpdate createDivide​(java.lang.Number divisor)
        Creates a new value update that divides a value. Note that the data type must be a numeric type.
        Parameters:
        divisor - the number to divide by
        Returns:
        a ValueUpdate specifying the division
        Throws:
        java.lang.UnsupportedOperationException - if the data type is non-numeric
      • createDivide

        public static ValueUpdate createDivide​(FieldValue key,
                                               java.lang.Number divisor)
        Creates a new value update that divides a weight in a weighted set. Note that this method is just a convenience method, it simply creates a divide value update by calling createDivide() and then creates a map value update by calling createMap() with the key and the divide value update as parameters.
        Parameters:
        key - the key whose weight in the weighted set to divide
        divisor - the number to divide by
        Returns:
        a ValueUpdate specifying the division
        See Also:
        createDivide(Number), createMap(FieldValue, ValueUpdate)
      • createAssign

        public static ValueUpdate createAssign​(FieldValue newValue)
        Creates a new value update that assigns a new value, completely overwriting the previous value.
        Parameters:
        newValue - the value to assign
        Returns:
        a ValueUpdate specifying the assignment
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of newValue does not match the type required
      • createClear

        public static ValueUpdate createClear()
        Creates a new value update that clears the field fromthe document.
        Returns:
        a ValueUpdate specifying the removal
      • createMap

        public static ValueUpdate createMap​(FieldValue value,
                                            ValueUpdate update)
        Creates a map value update, which is able to map an update to a value to a subvalue in an array or a weighted set. If this update is to be applied to an array, the value parameter must be an integer specifying the index in the array that the update parameter is to be applied to, and the update parameter must be compatible with the sub-datatype of the array. If this update is to be applied on a weighted set, the value parameter must be the key in the set that the update parameter is to be applied to, and the update parameter must be compatible with the INT data type.
        Parameters:
        value - the index in case of array, or key in case of weighted set
        update - the update to apply to the target sub-value
        Returns:
        a ValueUpdate specifying the sub-update
        Throws:
        java.lang.IllegalArgumentException - in case data type is an array type and value is not an Integer; in case data type is a weighted set type and value is not equal to the nested type of the weighted set; or the encapsulated update throws such an exception
        java.lang.UnsupportedOperationException - if superType is a single-value type, or anything else than array or weighted set; or the encapsulated update throws such an exception
      • createRemove

        public static ValueUpdate createRemove​(FieldValue value)
        Creates a new value update specifying the removal of a value from an array or a key/weight from a weighted set.
        Parameters:
        value - the value to remove from the array, or key to remove from the weighted set
        Returns:
        a ValueUpdate specifying the removal
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of newValue does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not array or weighted set
      • createRemoveAll

        public static java.util.List<ValueUpdate> createRemoveAll​(java.util.List<? extends FieldValue> values)
        Creates a new value update specifying the removal of all values in a given list from an array or weighted set. Note that this method is just a convenience method, it simply iterates through the list and creates value updates by calling createRemove() for each element.
        Parameters:
        values - a List containing the values to remove
        Returns:
        a List of ValueUpdates specifying the removal
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of values does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not array or weighted set
        See Also:
        createRemove(FieldValue)
      • createRemoveAll

        public static java.util.List<ValueUpdate> createRemoveAll​(WeightedSet<? extends FieldValue> values)
        Creates a new value update specifying the removal of all values in a given list from an array or weighted set. Note that this method is just a convenience method, it simply iterates through the list and creates value updates by calling createRemove() for each element.
        Parameters:
        values - a List containing the values to remove
        Returns:
        a List of ValueUpdates specifying the removal
        Throws:
        java.lang.IllegalArgumentException - if the runtime type of values does not match the type required
        java.lang.UnsupportedOperationException - if the field type is not array or weighted set
        See Also:
        createRemove(FieldValue)
      • getValue

        public abstract T getValue()
        Returns the primary "value" of this update, or null if this kind of update has no value
      • setValue

        public abstract void setValue​(T value)
        Sets the value of this. Ignored by update who have no value