Class DataObject.Builder

java.lang.Object
com.luciad.datamodels.DataObject.Builder
All Implemented Interfaces:
AutoCloseable
Enclosing class:
DataObject

public static final class DataObject.Builder extends Object implements AutoCloseable
Allows the incremental creation of a DataObject.

Configure the dataType() before calling value(). After build() is invoked once, the builder can no longer be used.

Example

    // A composite property holds a DataObject: build the nested object, then set it on the Feature.
    DataObject address = DataObject.newBuilder().dataType(addressType).value(streetPath, "Main St").build();
    Feature person = Feature.newBuilder().id(1L).dataType(personType).value(addressPath, address).build();
Since:
2026.1
  • Constructor Details

  • Method Details

    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • build

      @NotNull public DataObject build() throws IllegalStateException
      Builds the DataObject using the configured settings.

      After this method is invoked once, this builder can no longer be used.

      Returns:
      the DataObject.
      Throws:
      IllegalStateException - if the dataType is not configured.
    • dataType

      @NotNull public DataObject.Builder dataType(@NotNull DataType dataType)
      Configures the dataType of the DataObject being built.

      The DataType needs to be set before value() is called.

      Parameters:
      dataType - the data type.
      Returns:
      this builder.
    • resetValue

      @NotNull public DataObject.Builder resetValue(@NotNull String propertyName) throws IllegalArgumentException
      Convenience overload of resetValue that resolves the property by name on the configured data type and resets its value.

      The value type does not need to be named: it is derived from the property.

      The dataType() must be configured before this is called.

      Performance note: this overload resolves the name on every call. To reset the same property on many data objects in a tight loop, build a DataPropertyPath once and use the DataPropertyPath overload, which prevents the repeated lookup.

      Parameters:
      propertyName - the name of a property in the configured data type.
      Returns:
      this builder.
      Throws:
      IllegalArgumentException - when the dataType is not configured or no property with that name exists.
      Since:
      2026.1
    • value

      @NotNull public <T> DataObject.Builder value(@NotNull DataPropertyPath propertyPath, @NotNull T value) throws IllegalArgumentException
      Sets the value associated with the given property.

      The type parameter T depends on the type of value this property contains:

      • Scalar property: T is the element type.
      • Composite property (value type is a non-primitive DataType): T is DataObject, with a DataType that must equal the property's value type.
      • List property: T is the list type. One bulk set sizes and populates the list. Individual elements may be unset.
      • List element: T is the element type (DataObject for a composite element), and the single element is overwritten. The list must already have been bulk-set.
      Type Parameters:
      T - the value type, chosen by property shape (see above).
      Parameters:
      propertyPath - the property for which to set the value.
      value - the value.
      Returns:
      this builder.
      Throws:
      IllegalArgumentException - when the dataType has not been configured, the property does not exist in the DataType, T does not match the path's leaf type, or the list is unset or the index is out-of-bounds for an indexed path.
    • value

      @NotNull public DataObject.Builder value(@NotNull DataPropertyPath propertyPath, @NotNull List<?> values) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • resetValue

      @NotNull public DataObject.Builder resetValue(@NotNull DataPropertyPath propertyPath) throws IllegalArgumentException
      Resets the value associated with the given property to empty.

      The effect on a list-typed property depends on the path:

      • List path: the list is cleared (becomes unset).
      • List element: that single element is set to empty. The list must already be populated.
      Parameters:
      propertyPath - the property for which to reset the value.
      Returns:
      this builder.
      Throws:
      IllegalArgumentException - when the dataType has not been configured, the property doesn't exist, or the list is unset or the index is out-of-bounds for an indexed path.
    • value

      @NotNull public <T> DataObject.Builder value(@NotNull String propertyName, @NotNull T value) throws IllegalArgumentException
      Convenience overload of value that resolves the property by name on the configured data type and sets the value.

      The dataType() must be configured before this is called.

      Performance note: this overload resolves the name on every call. To set the same property on many data objects in a tight loop, build a DataPropertyPath once and use the DataPropertyPath overload, which prevents the repeated lookup.

      Type Parameters:
      T - the value type, chosen by the property's shape (see the DataPropertyPath overload).
      Parameters:
      propertyName - the name of a property in the configured data type.
      value - the value.
      Returns:
      this builder.
      Throws:
      IllegalArgumentException - when the dataType is not configured, no property with that name exists, or T does not match its type.
      Since:
      2026.1
    • value

      @NotNull public DataObject.Builder value(@NotNull String propertyName, @NotNull List<?> values) throws IllegalArgumentException
      Throws:
      IllegalArgumentException