Interface AttributesBuilder

All Superinterfaces:
Iterable<org.eclipse.ditto.json.JsonField>, org.eclipse.ditto.json.JsonObjectBuilder, org.eclipse.ditto.json.JsonValueContainer<org.eclipse.ditto.json.JsonField>

@NotThreadSafe public interface AttributesBuilder extends org.eclipse.ditto.json.JsonObjectBuilder
A mutable builder for a Attributes with a fluent API.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new Attributes object containing all values which were set to this builder beforehand.
    Removes the attribute from the Attributes to be built which is associated with the given name.
    remove(org.eclipse.ditto.json.JsonFieldDefinition<?> fieldDefinition)
    Removes the attribute from the Attributes to be built which is associated with the pointer of the specified JSON field definition.
    Removes all fields from the Attributes to be built.
    set(CharSequence key, boolean value)
    Sets a new boolean value attribute to the Attributes to be built.
    set(CharSequence key, boolean value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets a new boolean value attribute to the Attributes to be built if the specified predicate evaluates to true.
    set(CharSequence key, double value)
    Sets a new double value attribute to the Attributes to be built.
    set(CharSequence key, double value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets a new double value attribute to the Attributes to be built if the specified predicate evaluates to true.
    set(CharSequence key, int value)
    Sets a new int attribute to the Attributes to be built.
    set(CharSequence key, int value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets a new int attribute to the Attributes to be built if the specified predicate evaluates to true.
    set(CharSequence key, long value)
    Sets a new long attribute to the Attributes to be built.
    set(CharSequence key, long value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets a new long attribute to the Attributes to be built if the specified predicate evaluates to true.
    set(CharSequence key, String value)
    Sets a new string value attribute to the Attributes to be built.
    set(CharSequence key, String value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets a new string value attribute to the Attributes to be built if the specified predicate evaluates to true.
    set(CharSequence key, org.eclipse.ditto.json.JsonValue value)
    Sets a new JsonValue attribute to the Attributes to be built.
    set(CharSequence key, org.eclipse.ditto.json.JsonValue value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets a new JsonValue attribute to the Attributes to be built if the specified predicate evaluates to true.
    set(org.eclipse.ditto.json.JsonField field)
    Sets the specified attribute to the Attributes to be built.
    default <T> AttributesBuilder
    set(org.eclipse.ditto.json.JsonFieldDefinition<T> fieldDefinition, T value)
     
    set(org.eclipse.ditto.json.JsonFieldDefinition<T> fieldDefinition, T value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
     
    set(org.eclipse.ditto.json.JsonField field, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets the specified attribute to the Attributes to be built if the specified predicate evaluates to true.
    setAll(Iterable<org.eclipse.ditto.json.JsonField> fields)
    Sets the given JsonFields to the Attributes to be built.
    setAll(Iterable<org.eclipse.ditto.json.JsonField> fields, Predicate<org.eclipse.ditto.json.JsonField> predicate)
    Sets the given JsonFields to the Attributes to be built.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface org.eclipse.ditto.json.JsonValueContainer

    getSize, isEmpty, stream
  • Method Details

    • set

      AttributesBuilder set(CharSequence key, int value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets a new int attribute to the Attributes to be built if the specified predicate evaluates to true.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      default AttributesBuilder set(CharSequence key, int value)
      Sets a new int attribute to the Attributes to be built.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      AttributesBuilder set(CharSequence key, long value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets a new long attribute to the Attributes to be built if the specified predicate evaluates to true.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      default AttributesBuilder set(CharSequence key, long value)
      Sets a new long attribute to the Attributes to be built.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      AttributesBuilder set(CharSequence key, double value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets a new double value attribute to the Attributes to be built if the specified predicate evaluates to true.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      default AttributesBuilder set(CharSequence key, double value)
      Sets a new double value attribute to the Attributes to be built.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      AttributesBuilder set(CharSequence key, boolean value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets a new boolean value attribute to the Attributes to be built if the specified predicate evaluates to true.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      default AttributesBuilder set(CharSequence key, boolean value)
      Sets a new boolean value attribute to the Attributes to be built.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      AttributesBuilder set(CharSequence key, @Nullable String value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets a new string value attribute to the Attributes to be built if the specified predicate evaluates to true.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      default AttributesBuilder set(CharSequence key, @Nullable String value)
      Sets a new string value attribute to the Attributes to be built.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if name is empty.
    • set

      AttributesBuilder set(CharSequence key, org.eclipse.ditto.json.JsonValue value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets a new JsonValue attribute to the Attributes to be built if the specified predicate evaluates to true.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if any argument is null.
      IllegalArgumentException - if name is empty.
    • set

      default AttributesBuilder set(CharSequence key, org.eclipse.ditto.json.JsonValue value)
      Sets a new JsonValue attribute to the Attributes to be built.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be set.
      value - the value of the attribute to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if any argument is null.
      IllegalArgumentException - if name is empty.
    • set

      <T> AttributesBuilder set(org.eclipse.ditto.json.JsonFieldDefinition<T> fieldDefinition, @Nullable T value, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
    • set

      default <T> AttributesBuilder set(org.eclipse.ditto.json.JsonFieldDefinition<T> fieldDefinition, @Nullable T value)
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
    • set

      AttributesBuilder set(org.eclipse.ditto.json.JsonField field, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets the specified attribute to the Attributes to be built if the specified predicate evaluates to true. If this builder already contains a field with the same key, the existing one will be replaced.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      field - the field to be set.
      predicate - the predicate which finally determines if the attribute is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if field is null.
    • set

      default AttributesBuilder set(org.eclipse.ditto.json.JsonField field)
      Sets the specified attribute to the Attributes to be built. If this builder already contains a field with the same key, the existing one will be replaced.
      Specified by:
      set in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      field - the field to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if field is null.
    • remove

      Removes the attribute from the Attributes to be built which is associated with the given name. This method has no effect if no such field exists.
      Specified by:
      remove in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      key - the name of the attribute to be removed.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if name is null.
    • remove

      AttributesBuilder remove(org.eclipse.ditto.json.JsonFieldDefinition<?> fieldDefinition)
      Removes the attribute from the Attributes to be built which is associated with the pointer of the specified JSON field definition. This method has no effect if no such field exists.
      Specified by:
      remove in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      fieldDefinition - provides the JSON pointer of the attribute to be deleted.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if fieldDefinition is null.
      IllegalArgumentException - if the JSON pointer of fieldDefinition is empty.
    • setAll

      AttributesBuilder setAll(Iterable<org.eclipse.ditto.json.JsonField> fields, Predicate<org.eclipse.ditto.json.JsonField> predicate)
      Sets the given JsonFields to the Attributes to be built. This method prevents duplicates, i. e. if two fields have the same key, the previous field is replaced by the new field; the position of the new field in the resulting JSON object is the same as the position of the previous field. For each field applies that the field is only set if the specified predicate evaluates to true.
      Specified by:
      setAll in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      fields - the fields to set.
      predicate - the predicate which finally determines for each field if it is to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if fields is null.
    • setAll

      default AttributesBuilder setAll(Iterable<org.eclipse.ditto.json.JsonField> fields)
      Sets the given JsonFields to the Attributes to be built. This method prevents duplicates, i. e. if two fields have the same key, the previous field is replaced by the new field; the position of the new field in the resulting JSON object is the same as the position of the previous field.
      Specified by:
      setAll in interface org.eclipse.ditto.json.JsonObjectBuilder
      Parameters:
      fields - the fields to set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if fields is null.
    • removeAll

      AttributesBuilder removeAll()
      Removes all fields from the Attributes to be built.
      Specified by:
      removeAll in interface org.eclipse.ditto.json.JsonObjectBuilder
      Returns:
      this builder to allow method chaining.
    • build

      Attributes build()
      Creates a new Attributes object containing all values which were set to this builder beforehand.
      Specified by:
      build in interface org.eclipse.ditto.json.JsonObjectBuilder
      Returns:
      the new Attributes object.
      Throws:
      org.eclipse.ditto.json.JsonPointerInvalidException - if an attribute name in the passed jsonObject was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.