Class Data<T>
java.lang.Object
io.fluxzero.common.api.Data<T>
- Type Parameters:
T- the type of the value held in this container
- All Implemented Interfaces:
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 Fluxzero to represent serialized or intermediate values (e.g.:
JsonNode), often as part of SerializedMessage,
SerializedDocument, or key-value entries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCustom format identifier for document data used inSerializedDocument.static final StringStandard media type for JSON data. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs aDatainstance with aSupplierto support lazy access.Constructs aDatainstance without a specific format (defaults to JSON).Constructs aDatainstance with a fixed value and full metadata. -
Method Summary
Modifier and TypeMethodDescriptiondata()Returns this instance (forSerializedObjectcompatibility).booleanReturns the effective format for the data, defaulting toJSON_FORMATifformatis null or "json".getValue()Returns the deserialized value.inthashCode()<M> Data<M> map(ThrowingFunction<T, M> mapper) Transforms the value using a custom mapping function, while preserving serialization metadata.Replaces this instance with anotherDataobject.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SerializedObject
getRevision, getType
-
Field Details
-
JSON_FORMAT
-
DOCUMENT_FORMAT
Custom format identifier for document data used inSerializedDocument.- See Also:
-
-
Constructor Details
-
Data
@ConstructorProperties({"value","type","revision","format"}) public Data(T value, String type, int revision, String format) Constructs aDatainstance with a fixed value and full metadata. -
Data
-
Data
-
-
Method Details
-
getValue
Returns the deserialized value. This may trigger lazy loading via the supplier.- Returns:
- the deserialized object
-
getFormat
Returns the effective format for the data, defaulting toJSON_FORMATifformatis null or "json". -
equals
-
hashCode
-
data
Returns this instance (forSerializedObjectcompatibility).- Specified by:
datain interfaceSerializedObject<T>- Returns:
- the serialized payload
-
withData
Replaces this instance with anotherDataobject. This method simply returns the provided argument (identity transform).- Specified by:
withDatain interfaceSerializedObject<T>- Parameters:
data- the new serialized payload- Returns:
- a new
SerializedObjectinstance. May bethisif unchanged
-
map
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
-