/** * Set the value for the field with the given name to the supplied double value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, double value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied big integer value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, BigDecimal value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied string value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setString(int index, String value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied boolean value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setBoolean(int index, boolean value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to be a binary value. The value will be encoded as Base64. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param data the bytes for the binary value * @return this array to allow for chaining methods */ default Array setBinary(int index, byte[] data) { return setValue(index, Value.create(data)); }
/** * Set the value for the field with the given name to the supplied float value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, float value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied big integer value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, BigInteger value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied long value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, long value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied integer value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, int value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to be a null value. The {@link #isNull(int)} methods can be used to * determine if a field has been set to null, or {@link #isNullOrMissing(int)} if the field has not be set or if it has * been set to null. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @return this array to allow for chaining methods * @see #isNull(int) * @see #isNullOrMissing(int) */ default Array setNull(int index) { return setValue(index, Value.nullValue()); }
/** * Set the value for the field with the given name to be the supplied array. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param values the (valid) values for the array * @return The array that was just set as the value for the named field; never null and may or may not be the same * instance as the supplied <code>array</code>. */ default Array setArray(int index, Value... values) { Array array = Array.create(values); setValue(index, Value.create(array)); return array; }
/** * Set the value for the field with the given name to be the supplied Document. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param document the document * @return The document that was just set as the value for the named field; never null and may or may not be the same * instance as the supplied <code>document</code>. */ default Document setDocument(int index, Document document) { if (document == null) document = Document.create(); setValue(index, Value.create(document)); return document; }
/** * Set the value for the field with the given name to be the supplied array. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param array the array * @return The array that was just set as the value for the named field; never null and may or may not be the same * instance as the supplied <code>array</code>. */ default Array setArray(int index, Array array) { if (array == null) array = Array.create(); setValue(index, Value.create(array)); return array; }
/** * Transform all of the field values using the supplied {@link BiFunction transformer function}. * * @param transformer the transformer that should be used to transform each field value; may not be null * @return this array with transformed fields, or this document if the transformer changed none of the values */ default Array transform(BiFunction<Integer, Value, Value> transformer) { for (int i = 0; i != size(); ++i) { Value existing = get(i); Value updated = transformer.apply(Integer.valueOf(i), existing); if (updated == null) updated = Value.nullValue(); if (updated != existing) { setValue(i, updated); } } return this; }
/** * Sets on this object all key/value pairs from the supplied map. If the supplied map is null, this method does nothing. * * @param entries the entries that are to be used to modify this array * @return this array to allow for chaining methods */ default Array putAll(Iterable<Entry> entries) { if (entries != null) { entries.forEach(entry -> { if (entry != null) { Value value = entry.getValue().clone(); setValue(entry.getIndex(), value); } }); } return this; }
} else { int index = Path.Segments.asInteger(lastSegment).get(); array.setValue(index, value);
/** * Set the value for the field with the given name to the supplied boolean value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setBoolean(int index, boolean value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied string value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setString(int index, String value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied integer value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, int value) { return setValue(index, Value.create(value)); }
/** * Set the value for the field with the given name to the supplied big integer value. * * @param index the index of the field; must be greater than or equal to 0 or less than or equal to {@link #size() size} * @param value the new value for the field * @return this array to allow for chaining methods */ default Array setNumber(int index, BigInteger value) { return setValue(index, Value.create(value)); }