/** * 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. * * @param values a List containing the values to remove * @return a List of ValueUpdates specifying the removal * @throws IllegalArgumentException if the runtime type of values does not match the type required * @throws UnsupportedOperationException if the field type is not array or weighted set * @see ValueUpdate#createRemove(FieldValue) */ public static List<ValueUpdate> createRemoveAll(List<? extends FieldValue> values) { List<ValueUpdate> vupds = new ArrayList<>(); for (FieldValue value : values) { vupds.add(ValueUpdate.createRemove(value)); } return vupds; }
/** * Creates a new field update, with one encapsulated value update, * specifying the removal of a value from an array or a key/weight from a weighted set. * * @param field the field to remove a value from * @param value the value to remove from the array, or key to remove from the weighted set * @return a FieldUpdate 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 * @see ValueUpdate#createRemove(FieldValue) */ public static FieldUpdate createRemove(Field field, FieldValue value) { return new FieldUpdate(field, ValueUpdate.createRemove(value)); }
/** * 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. * * @param values a List containing the values to remove * @return a List of ValueUpdates specifying the removal * @throws IllegalArgumentException if the runtime type of values does not match the type required * @throws UnsupportedOperationException if the field type is not array or weighted set * @see ValueUpdate#createRemove(FieldValue) */ public static List<ValueUpdate> createRemoveAll(WeightedSet<? extends FieldValue> values) { List<ValueUpdate> vupds = new ArrayList<>(); for (FieldValue value : values.keySet()) { vupds.add(ValueUpdate.createRemove(value)); } return vupds; }