Interface DittoHeadersBuilder<B extends DittoHeadersBuilder<B,R>,R extends DittoHeaders>
-
- Type Parameters:
B
- the type of the class which implements this interface; this type is used as return value for Method Chaining.R
- the type of the built DittoHeaders object.
- All Known Implementing Classes:
AbstractDittoHeadersBuilder
@NotThreadSafe public interface DittoHeadersBuilder<B extends DittoHeadersBuilder<B,R>,R extends DittoHeaders>
This interface represents a mutable builder with a fluent API for aDittoHeaders
object or an object of a descendant type.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description B
acknowledgementRequest(AcknowledgementRequest acknowledgementRequest, AcknowledgementRequest... furtherAcknowledgementRequests)
Sets the acknowledgements ("ACK") which are requested together with an issued DittoCommand
.B
acknowledgementRequests(Collection<AcknowledgementRequest> acknowledgementRequests)
Sets the acknowledgements ("ACK") which are requested together with an issued DittoCommand
.B
allowPolicyLockout(boolean allowPolicyLockout)
Sets the allowPolicyLockout value.B
authorizationContext(AuthorizationContext authorizationContext)
Sets the authorization context value.B
authorizationSubjects(CharSequence authorizationSubject, CharSequence... furtherAuthorizationSubjects)
Deprecated.as of 1.1.0, please useauthorizationContext(AuthorizationContext)
instead for adding theauthorizationSubjects
B
authorizationSubjects(Collection<String> authorizationSubjectIds)
Deprecated.as of 1.1.0, please useauthorizationContext(AuthorizationContext)
instead for adding theauthorizationSubjects
R
build()
Creates a DittoHeaders object containing the key-value-pairs which were put to this builder.B
channel(CharSequence channel)
Sets the specified String as channel of the Signal/Exception.B
contentType(CharSequence contentType)
Sets the contentType value.B
contentType(ContentType contentType)
Sets the Ditto typed contentType value.B
correlationId(CharSequence correlationId)
Sets the specified correlation ID.B
dryRun(boolean dryRun)
Sets the dryRun value.B
eTag(EntityTag eTag)
Sets the ETag value.B
expectedResponseTypes(Collection<ResponseType> responseTypes)
Set the expected response types.B
expectedResponseTypes(ResponseType... responseTypes)
Set the expected response types.B
ifMatch(EntityTagMatchers entityTags)
Sets the If-Match value.B
ifNoneMatch(EntityTagMatchers entityTags)
Sets the If-None-Match value.B
inboundPayloadMapper(String inboundPayloadMapperId)
Sets the inboundMessageMapper
ID value.B
origin(CharSequence origin)
Sets the origin value.B
putHeader(CharSequence key, CharSequence value)
Puts an arbitrary header with the specifiedname
and Stringvalue
to this builder.B
putHeaders(Map<String,String> headers)
Puts the specified headers to this builder.B
putMetadata(MetadataHeaderKey key, org.eclipse.ditto.json.JsonValue value)
Puts the given metadata association to this builder.default B
randomCorrelationId()
Sets a generated random correlation ID.B
readGrantedSubjects(Collection<AuthorizationSubject> readGrantedSubjects)
Sets the subjects with granted READ access.B
readRevokedSubjects(Collection<AuthorizationSubject> readRevokedSubjects)
Sets the subjects with explicitly revoked READ access.B
readSubjects(Collection<String> readSubjects)
Deprecated.as of 1.1.0, please usereadGrantedSubjects(Collection)
.B
removeHeader(CharSequence key)
Removes from this builder the value which is associated with the specified key.B
removePreconditionHeaders()
Removes all precondition headers from this builder.B
replyTarget(Integer replyTarget)
Set the reply-target.B
responseRequired(boolean responseRequired)
Sets the responseRequired value.B
schemaVersion(JsonSchemaVersion schemaVersion)
Sets the json schema version value.B
timeout(CharSequence timeoutStr)
Sets the positive timeout string of the DittoHeaders to build.B
timeout(Duration timeout)
Sets the positive timeout duration of the DittoHeaders to build.
-
-
-
Method Detail
-
correlationId
B correlationId(@Nullable CharSequence correlationId)
Sets the specified correlation ID.- Parameters:
correlationId
- the correlation ID to be set.- Returns:
- this builder for Method Chaining.
- Throws:
IllegalArgumentException
- ifcorrelationId
is empty.
-
randomCorrelationId
default B randomCorrelationId()
Sets a generated random correlation ID.- Returns:
- this builder for Method Chaining.
-
schemaVersion
B schemaVersion(@Nullable JsonSchemaVersion schemaVersion)
Sets the json schema version value.- Parameters:
schemaVersion
- the "schema version" value to be set.- Returns:
- this builder for Method Chaining.
-
authorizationContext
B authorizationContext(@Nullable AuthorizationContext authorizationContext)
Sets the authorization context value.- Parameters:
authorizationContext
- the "authorizationContext" value to be set.- Returns:
- this builder for Method Chaining.
-
authorizationSubjects
@Deprecated B authorizationSubjects(Collection<String> authorizationSubjectIds)
Deprecated.as of 1.1.0, please useauthorizationContext(AuthorizationContext)
instead for adding theauthorizationSubjects
Sets the IDs of Authorization Subjects.- Parameters:
authorizationSubjectIds
- the IDs to be set.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- ifauthorizationSubjectIds
isnull
.
-
authorizationSubjects
@Deprecated B authorizationSubjects(CharSequence authorizationSubject, CharSequence... furtherAuthorizationSubjects)
Deprecated.as of 1.1.0, please useauthorizationContext(AuthorizationContext)
instead for adding theauthorizationSubjects
Sets the authorizationSubjects value.- Parameters:
authorizationSubject
- the authorizationSubject value to be set.furtherAuthorizationSubjects
- further of "authorized subjects" to be set.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
readSubjects
@Deprecated B readSubjects(Collection<String> readSubjects)
Deprecated.as of 1.1.0, please usereadGrantedSubjects(Collection)
.Sets the readSubjects value.- Parameters:
readSubjects
- the readSubjects value to be set.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- ifreadSubjects
isnull
.
-
readGrantedSubjects
B readGrantedSubjects(Collection<AuthorizationSubject> readGrantedSubjects)
Sets the subjects with granted READ access.- Parameters:
readGrantedSubjects
- the value to be set.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- ifreadGrantedSubjects
isnull
.- Since:
- 1.1.0
-
readRevokedSubjects
B readRevokedSubjects(Collection<AuthorizationSubject> readRevokedSubjects)
Sets the subjects with explicitly revoked READ access.- Parameters:
readRevokedSubjects
- the value to be set.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- ifreadRevokedSubjects
isnull
.- Since:
- 1.1.0
-
channel
B channel(@Nullable CharSequence channel)
Sets the specified String as channel of the Signal/Exception.- Parameters:
channel
- the channel of the Signal/Exception to be set.- Returns:
- this builder for Method Chaining.
- Throws:
IllegalArgumentException
- ifchannel
is empty.
-
responseRequired
B responseRequired(boolean responseRequired)
Sets the responseRequired value. Call this method for explicitly waiving a response. Please note: If ACK requests are set (seeacknowledgementRequests(Collection)
calling this method has no effect. ACK requests always imply that a response is required.- Parameters:
responseRequired
- the responseRequired value to be set.- Returns:
- this builder for Method Chaining.
-
dryRun
B dryRun(boolean dryRun)
Sets the dryRun value.- Parameters:
dryRun
- the dryRun value to be set.- Returns:
- this builder for Method Chaining.
-
origin
B origin(CharSequence origin)
Sets the origin value.- Parameters:
origin
- the origin value to be set.- Returns:
- this builder for Method Chaining.
-
contentType
B contentType(@Nullable CharSequence contentType)
Sets the contentType value.- Parameters:
contentType
- the contentType value to be set.- Returns:
- this builder for Method Chaining.
-
contentType
B contentType(@Nullable ContentType contentType)
Sets the Ditto typed contentType value.- Parameters:
contentType
- the Ditto typed contentType value to be set.- Returns:
- this builder for Method Chaining.
- Since:
- 1.3.0
-
eTag
B eTag(EntityTag eTag)
Sets the ETag value.- Parameters:
eTag
- The ETag value to be set.- Returns:
- this builder for Method Chaining
-
ifMatch
B ifMatch(EntityTagMatchers entityTags)
Sets the If-Match value.- Parameters:
entityTags
- The entity tags where one should match.- Returns:
- this builder for Method Chaining
-
ifNoneMatch
B ifNoneMatch(EntityTagMatchers entityTags)
Sets the If-None-Match value.- Parameters:
entityTags
- The entity tags that must not match.- Returns:
- this builder for Method Chaining
-
inboundPayloadMapper
B inboundPayloadMapper(@Nullable String inboundPayloadMapperId)
Sets the inboundMessageMapper
ID value.- Parameters:
inboundPayloadMapperId
- the inboundMessageMapper
ID which mapped incoming arbitrary payload from external sources. If null, the header will be removed.- Returns:
- this builder for Method Chaining
-
replyTarget
B replyTarget(@Nullable Integer replyTarget)
Set the reply-target.- Parameters:
replyTarget
- the reply-target identifier.- Returns:
- this builder.
-
expectedResponseTypes
B expectedResponseTypes(ResponseType... responseTypes)
Set the expected response types. In combination withreplyTarget(Integer)
this decides which type of responses are delivered to a reply target of a connection source.- Parameters:
responseTypes
- the response types that should be delivered to a reply target.- Returns:
- this builder.
- Since:
- 1.2.0
-
expectedResponseTypes
B expectedResponseTypes(Collection<ResponseType> responseTypes)
Set the expected response types. In combination withreplyTarget(Integer)
this decides which type of responses are delivered to a reply target of a connection source.- Parameters:
responseTypes
- the response types that should be delivered to a reply target.- Returns:
- this builder.
- Since:
- 1.2.0
-
acknowledgementRequests
B acknowledgementRequests(Collection<AcknowledgementRequest> acknowledgementRequests)
Sets the acknowledgements ("ACK") which are requested together with an issued DittoCommand
. Such ACKs are sent back to the issuer of the command so that it can be verified which steps were successful.In addition to built-in ACK labels like
DittoAcknowledgementLabel.TWIN_PERSISTED
also custom labels may be used which can be sent back even by external systems.- Parameters:
acknowledgementRequests
- the requests for acknowledgements.- Returns:
- this builder.
- Throws:
NullPointerException
- ifacknowledgementRequests
isnull
.- Since:
- 1.1.0
-
acknowledgementRequest
B acknowledgementRequest(AcknowledgementRequest acknowledgementRequest, AcknowledgementRequest... furtherAcknowledgementRequests)
Sets the acknowledgements ("ACK") which are requested together with an issued DittoCommand
. Such ACKs are sent back to the issuer of the command so that it can be verified which steps were successful.In addition to built-in ACK labels like
DittoAcknowledgementLabel.TWIN_PERSISTED
also custom labels may be used which can be sent back even by external systems.As long as ACKs are requested, calls of
responseRequired(boolean)
are neglected as requested ACKs always imply that a response is required.- Parameters:
acknowledgementRequest
- the request for an acknowledgement.furtherAcknowledgementRequests
- further requests for acknowledgements.- Returns:
- this builder.
- Throws:
NullPointerException
- if any argument isnull
.- Since:
- 1.1.0
-
timeout
B timeout(@Nullable CharSequence timeoutStr)
Sets the positive timeout string of the DittoHeaders to build.- Parameters:
timeoutStr
- the duration of the command containing the DittoHeaders to time out.- Returns:
- this builder.
- Throws:
DittoHeaderInvalidException
- if the given timeout char sequence does not contain a parsable duration or if the duration is negative.- Since:
- 1.1.0
-
timeout
B timeout(@Nullable Duration timeout)
Sets the positive timeout duration of the DittoHeaders to build.- Parameters:
timeout
- the duration of the command containing the DittoHeaders to time out.- Returns:
- this builder.
- Throws:
IllegalArgumentException
- iftimeout
is negative.- Since:
- 1.1.0
-
putMetadata
B putMetadata(MetadataHeaderKey key, org.eclipse.ditto.json.JsonValue value)
Puts the given metadata association to this builder. An existing entry with the same key will be replaced.- Parameters:
key
- the metadata key.value
- the metadata value.- Returns:
- this builder.
- Since:
- 1.2.0
-
allowPolicyLockout
B allowPolicyLockout(boolean allowPolicyLockout)
Sets the allowPolicyLockout value.- Parameters:
allowPolicyLockout
- the allowPolicyLockout value to be set.- Returns:
- this builder for method chaining.
- Since:
- 1.3.0
-
putHeader
B putHeader(CharSequence key, CharSequence value)
Puts an arbitrary header with the specifiedname
and Stringvalue
to this builder.- Parameters:
key
- the header name to use.value
- the String value.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- if any argument isnull
.IllegalArgumentException
- if key is emptyDittoHeaderInvalidException
- ifvalue
represents an invalid Java type.
-
putHeaders
B putHeaders(Map<String,String> headers)
Puts the specified headers to this builder. Existing headers with the same key will be replaced.- Parameters:
headers
- the headers to be put.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- ifheaders
isnull
.DittoHeaderInvalidException
- ifheaders
contains a value that did not represent its appropriate Java type.
-
removeHeader
B removeHeader(CharSequence key)
Removes from this builder the value which is associated with the specified key.- Parameters:
key
- the key to remove the associated value for.- Returns:
- this builder for Method Chaining.
- Throws:
NullPointerException
- ifkey
isnull
.IllegalArgumentException
- ifkey
is empty.
-
removePreconditionHeaders
B removePreconditionHeaders()
Removes all precondition headers from this builder.- Returns:
- The builder without preconditionHeaders
-
build
R build()
Creates a DittoHeaders object containing the key-value-pairs which were put to this builder.- Returns:
- the headers.
-
-