Interface Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T>
-
- Type Parameters:
J
- the type of the JSON result.T
- the type which the predicate consumes for evaluation.
- All Superinterfaces:
Jsonifiable<J>
- All Known Subinterfaces:
AuthorizationContext
,Entity<T>
,FilteredAcknowledgementRequest
,Jsonifiable.WithFieldSelectorAndPredicate<T>
,Metadata
- All Known Implementing Classes:
AcknowledgementLabelInvalidException
,AcknowledgementLabelNotDeclaredException
,AcknowledgementLabelNotUniqueException
,AcknowledgementRequestParseException
,CloudEventMissingPayloadException
,CloudEventNotParsableException
,CloudEventUnsupportedDataSchemaException
,DittoAcknowledgementLabelExternalUseForbiddenException
,DittoHeaderInvalidException
,DittoHeadersTooLargeException
,DittoJsonException
,DittoRuntimeException
,InvalidRqlExpressionException
,NamespacedEntityIdInvalidException
,PubSubTerminatedException
,SignalEnrichmentFailedException
,TimeoutInvalidException
,TooManyRequestsException
,UnsupportedMediaTypeException
- Enclosing interface:
- Jsonifiable<J extends org.eclipse.ditto.json.JsonValue>
public static interface Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T> extends Jsonifiable<J>
Represents aJsonifiable
where additionally aPredicate
can be specified which determines the content of the result JSON. The predicate is parametrized as only the implementing class knows how the JSON is being created. In the following example an object is jsonified but only those fields should be included which are part of a particular schema version. First the declaration of the object's class:public final class MyObject implements Jsonifiable.WithPredicate<JsonField> { ... }
Then the method invocation for creating a JSON object of a particular JSON schema version.final MyObject myObject = ...; final JsonValue myObjectJson = myObject.toJson(JsonSchemaVersion.V_1);
This works becauseJsonSchemaVersion
implementsPredicate<JsonField>
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
Jsonifiable.WithFieldSelector, Jsonifiable.WithFieldSelectorAndPredicate<T>, Jsonifiable.WithPointer<J extends org.eclipse.ditto.json.JsonValue>, Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default J
toJson(Predicate<T> predicate)
Returns this object asJsonValue
.J
toJson(JsonSchemaVersion schemaVersion, Predicate<T> predicate)
Returns this object asJsonValue
.default String
toJsonString(Predicate<T> predicate)
Returns a JSON string representation of this object.default String
toJsonString(JsonSchemaVersion schemaVersion, Predicate<T> predicate)
Returns a JSON string representation of this object.-
Methods inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
getImplementedSchemaVersion, getLatestSchemaVersion, getSupportedSchemaVersions, implementsSchemaVersion, implementsSchemaVersion, toJson, toJsonString
-
-
-
-
Method Detail
-
toJson
default J toJson(Predicate<T> predicate)
Returns this object asJsonValue
. The content of the result is determined by the given predicate.- Parameters:
predicate
- determines the content of the result.- Returns:
- a JSON value representation of this object.
- Throws:
NullPointerException
- ifpredicate
isnull
.
-
toJson
J toJson(JsonSchemaVersion schemaVersion, Predicate<T> predicate)
Returns this object asJsonValue
. The content of the result is determined by the given predicate.- Parameters:
schemaVersion
- the JsonSchemaVersion in which to return the JSON.predicate
- determines the content of the result.- Returns:
- a JSON value representation of this object.
- Throws:
NullPointerException
- ifpredicate
isnull
.
-
toJsonString
default String toJsonString(Predicate<T> predicate)
Returns a JSON string representation of this object. The content of the result is determined by the given predicate.- Parameters:
predicate
- determines the content of the result.- Returns:
- a JSON string representation of this object.
- Throws:
NullPointerException
- ifpredicate
isnull
.- See Also:
toJson(Predicate)
-
toJsonString
default String toJsonString(JsonSchemaVersion schemaVersion, Predicate<T> predicate)
Returns a JSON string representation of this object. The content of the result is determined by the given predicate.- Parameters:
schemaVersion
- the JsonSchemaVersion in which to return the JSON.predicate
- determines the content of the result.- Returns:
- a JSON string representation of this object.
- Throws:
NullPointerException
- ifpredicate
isnull
.- See Also:
toJson(JsonSchemaVersion, Predicate)
-
-