Class DataAddParams.Data
-
- All Implemented Interfaces:
public final class DataAddParams.DataA data object to ingest. It must include an id field. All other fields are flexible and can be any JSON type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceDataAddParams.Data.VisitorAn interface that defines how to map each variant of Data to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<DataObject>dataObject()A data object to ingest. final Optional<List<DataObject>>objectArray()Array of data objects to ingest. final BooleanisDataObject()final BooleanisObjectArray()final DataObjectasDataObject()A data object to ingest. final List<DataObject>asObjectArray()Array of data objects to ingest. final Optional<JsonValue>_json()final <T extends Any> Taccept(DataAddParams.Data.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final DataAddParams.Datavalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static DataAddParams.DataofDataObject(DataObject dataObject)A data object to ingest. final static DataAddParams.DataofObjectArray(List<DataObject> objectArray)Array of data objects to ingest. -
-
Method Detail
-
dataObject
final Optional<DataObject> dataObject()
A data object to ingest. It must include an id field. All other fields are flexible and can be any JSON type.
-
objectArray
final Optional<List<DataObject>> objectArray()
Array of data objects to ingest.
-
isDataObject
final Boolean isDataObject()
-
isObjectArray
final Boolean isObjectArray()
-
asDataObject
final DataObject asDataObject()
A data object to ingest. It must include an id field. All other fields are flexible and can be any JSON type.
-
asObjectArray
final List<DataObject> asObjectArray()
Array of data objects to ingest.
-
accept
final <T extends Any> T accept(DataAddParams.Data.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.safetykit.core.JsonValue; import java.util.Optional; Optional<String> result = data.accept(new Data.Visitor<Optional<String>>() { @Override public Optional<String> visitDataObject(DataObject dataObject) { return Optional.of(dataObject.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final DataAddParams.Data validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofDataObject
final static DataAddParams.Data ofDataObject(DataObject dataObject)
A data object to ingest. It must include an id field. All other fields are flexible and can be any JSON type.
-
ofObjectArray
final static DataAddParams.Data ofObjectArray(List<DataObject> objectArray)
Array of data objects to ingest.
-
-
-
-