/** * 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; }
public static <T extends FieldValue> void serializeWeightedSet(JsonGenerator generator, FieldBase field, WeightedSet<T> value) { fieldNameIfNotNull(generator, field); wrapIOException(() -> { generator.writeStartObject(); for (T key : value.keySet()) { Integer weight = value.get(key); // key.toString() is according to spec generator.writeNumberField(key.toString(), weight); } generator.writeEndObject(); }); }