Class Data<T>

java.lang.Object
io.fluxcapacitor.common.api.Data<T>
Type Parameters:
T - the type of the value held in this container
All Implemented Interfaces:
SerializedObject<T>

public class Data<T> extends Object implements SerializedObject<T>
A generic container for holding a value along with serialization metadata such as type, revision, and format.

This class is used extensively throughout Flux Capacitor to represent serialized or intermediate values (e.g.: JsonNode), often as part of SerializedMessage, SerializedDocument, or key-value entries.

  • Field Details

  • Constructor Details

    • Data

      @ConstructorProperties({"value","type","revision","format"}) public Data(T value, String type, int revision, String format)
      Constructs a Data instance with a fixed value and full metadata.
    • Data

      public Data(T value, String type, int revision)
      Constructs a Data instance without a specific format (defaults to JSON).
    • Data

      public Data(Supplier<T> value, String type, int revision, String format)
      Constructs a Data instance with a Supplier to support lazy access.
  • Method Details

    • getValue

      public T getValue()
      Returns the deserialized value. This may trigger lazy loading via the supplier.
      Returns:
      the deserialized object
    • getFormat

      public String getFormat()
      Returns the effective format for the data, defaulting to JSON_FORMAT if format is null or "json".
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • data

      public Data<T> data()
      Returns this instance (for SerializedObject compatibility).
      Specified by:
      data in interface SerializedObject<T>
      Returns:
      the serialized payload
    • withData

      public Data<T> withData(Data<T> data)
      Replaces this instance with another Data object. This method simply returns the provided argument (identity transform).
      Specified by:
      withData in interface SerializedObject<T>
      Parameters:
      data - the new serialized payload
      Returns:
      a new SerializedObject instance. May be this if unchanged
    • map

      public <M> Data<M> map(ThrowingFunction<T,M> mapper)
      Transforms the value using a custom mapping function, while preserving serialization metadata.
      Type Parameters:
      M - result type after mapping
      Parameters:
      mapper - transformation function that may throw an exception
      Returns:
      a new Data<M> with the mapped value and original serialization metadata