Class ImmutableChange
- java.lang.Object
-
- org.eclipse.ditto.client.changes.internal.ImmutableChange
-
- All Implemented Interfaces:
org.eclipse.ditto.base.model.entity.id.WithEntityId
,org.eclipse.ditto.base.model.entity.type.WithEntityType
,org.eclipse.ditto.base.model.headers.DittoHeadersSettable<Change>
,org.eclipse.ditto.base.model.headers.WithDittoHeaders
,Acknowledgeable
,Change
@Immutable public final class ImmutableChange extends java.lang.Object implements Change
An immutable holder for anEntityId
and aChangeAction
. Objects of this class are meant to be used in a composition scenario.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description ImmutableChange(org.eclipse.ditto.base.model.entity.id.EntityId entityId, ChangeAction changeAction, org.eclipse.ditto.json.JsonPointer path, org.eclipse.ditto.json.JsonValue value, long revision, java.time.Instant timestamp, org.eclipse.ditto.json.JsonObject extra, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders, java.util.function.Consumer<org.eclipse.ditto.base.model.signals.acks.Acknowledgement> acknowledgementPublisher)
Constructs a newImmutableChange
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
ChangeAction
getAction()
Returns theChangeAction
which caused this change.org.eclipse.ditto.base.model.headers.DittoHeaders
getDittoHeaders()
org.eclipse.ditto.base.model.entity.id.EntityId
getEntityId()
org.eclipse.ditto.base.model.entity.type.EntityType
getEntityType()
java.util.Optional<org.eclipse.ditto.json.JsonObject>
getExtra()
Returns the extra information which enriches the actual value of this change.org.eclipse.ditto.json.JsonPointer
getPath()
Returns the relative path (relative to the change registration) of the changed JSON field.long
getRevision()
Returns the revision (change counter) of the change.java.util.Optional<java.time.Instant>
getTimestamp()
Returns the timestamp of the change.java.util.Optional<org.eclipse.ditto.json.JsonValue>
getValue()
Returns the optional value of the changed JSON field.void
handleAcknowledgementRequest(org.eclipse.ditto.base.model.acks.AcknowledgementLabel acknowledgementLabel, java.util.function.Consumer<AcknowledgementRequestHandle> acknowledgementHandle)
Handles anAcknowledgementRequest
identified by the passedacknowledgementLabel
issued by the Ditto backend for a received signal translated into this Acknowledgeable by invoking the passedacknowledgementHandle
consumer with a client sideAcknowledgementHandle
- if the passed acknowledgementLabel was present in the requested acknowledgements.void
handleAcknowledgementRequests(java.util.function.Consumer<java.util.Collection<AcknowledgementRequestHandle>> acknowledgementHandles)
HandlesAcknowledgementRequest
s issued by the Ditto backend for a received signal translated into this Acknowledgeable by invoking the passedacknowledgementHandles
consumer with client sideAcknowledgementHandle
s.int
hashCode()
Change
setDittoHeaders(org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
java.lang.String
toString()
Change
withExtra(org.eclipse.ditto.json.JsonObject extra)
Sets the given extra information which enriches the actual value of the change.Change
withPathAndValue(org.eclipse.ditto.json.JsonPointer path, org.eclipse.ditto.json.JsonValue value)
Sets the givenpath
andvalue
into the change.
-
-
-
Constructor Detail
-
ImmutableChange
public ImmutableChange(org.eclipse.ditto.base.model.entity.id.EntityId entityId, ChangeAction changeAction, org.eclipse.ditto.json.JsonPointer path, @Nullable org.eclipse.ditto.json.JsonValue value, long revision, @Nullable java.time.Instant timestamp, @Nullable org.eclipse.ditto.json.JsonObject extra, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders, java.util.function.Consumer<org.eclipse.ditto.base.model.signals.acks.Acknowledgement> acknowledgementPublisher)
Constructs a newImmutableChange
object.- Parameters:
entityId
- ID (with EntityType) of the changed entity.changeAction
- the operation which caused the change.path
- the JsonPointer of the changed json field.value
- the value of the changed json field.revision
- the revision (change counter) of the change.timestamp
- the timestamp of the change.extra
- the extra data to be included in the change.dittoHeaders
- the DittoHeaders of the event which lead to the change.acknowledgementPublisher
- the consumer for publishing built acknowledgements to the Ditto backend.- Throws:
java.lang.NullPointerException
- if any required argument isnull
.
-
-
Method Detail
-
getEntityId
public org.eclipse.ditto.base.model.entity.id.EntityId getEntityId()
- Specified by:
getEntityId
in interfaceorg.eclipse.ditto.base.model.entity.id.WithEntityId
-
getEntityType
public org.eclipse.ditto.base.model.entity.type.EntityType getEntityType()
- Specified by:
getEntityType
in interfaceorg.eclipse.ditto.base.model.entity.type.WithEntityType
-
getAction
public ChangeAction getAction()
Description copied from interface:Change
Returns theChangeAction
which caused this change.
-
getPath
public org.eclipse.ditto.json.JsonPointer getPath()
Description copied from interface:Change
Returns the relative path (relative to the change registration) of the changed JSON field.
-
getValue
public java.util.Optional<org.eclipse.ditto.json.JsonValue> getValue()
Description copied from interface:Change
Returns the optional value of the changed JSON field.
-
getRevision
public long getRevision()
Description copied from interface:Change
Returns the revision (change counter) of the change.- Specified by:
getRevision
in interfaceChange
- Returns:
- the revision of the change.
-
getTimestamp
public java.util.Optional<java.time.Instant> getTimestamp()
Description copied from interface:Change
Returns the timestamp of the change.- Specified by:
getTimestamp
in interfaceChange
- Returns:
- the timestamp of the change.
-
getExtra
public java.util.Optional<org.eclipse.ditto.json.JsonObject> getExtra()
Description copied from interface:Change
Returns the extra information which enriches the actual value of this change.
-
withExtra
public Change withExtra(@Nullable org.eclipse.ditto.json.JsonObject extra)
Description copied from interface:Change
Sets the given extra information which enriches the actual value of the change. Previously set extra is replaced.
-
getDittoHeaders
public org.eclipse.ditto.base.model.headers.DittoHeaders getDittoHeaders()
- Specified by:
getDittoHeaders
in interfaceorg.eclipse.ditto.base.model.headers.WithDittoHeaders
-
setDittoHeaders
public Change setDittoHeaders(org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
- Specified by:
setDittoHeaders
in interfaceorg.eclipse.ditto.base.model.headers.DittoHeadersSettable<Change>
-
handleAcknowledgementRequests
public void handleAcknowledgementRequests(java.util.function.Consumer<java.util.Collection<AcknowledgementRequestHandle>> acknowledgementHandles)
Description copied from interface:Acknowledgeable
HandlesAcknowledgementRequest
s issued by the Ditto backend for a received signal translated into this Acknowledgeable by invoking the passedacknowledgementHandles
consumer with client sideAcknowledgementHandle
s.- Specified by:
handleAcknowledgementRequests
in interfaceAcknowledgeable
- Parameters:
acknowledgementHandles
- the consumer to invoke with a collection ofAcknowledgementHandle
s used to send backAcknowledgements
.
-
withPathAndValue
public Change withPathAndValue(org.eclipse.ditto.json.JsonPointer path, @Nullable org.eclipse.ditto.json.JsonValue value)
Description copied from interface:Change
Sets the givenpath
andvalue
into the change.- Specified by:
withPathAndValue
in interfaceChange
- Parameters:
path
- the relative path of the changed JSON field.value
- the optional value of the changed JSON field.- Returns:
- a new instance of this change with the added data.
-
handleAcknowledgementRequest
public void handleAcknowledgementRequest(org.eclipse.ditto.base.model.acks.AcknowledgementLabel acknowledgementLabel, java.util.function.Consumer<AcknowledgementRequestHandle> acknowledgementHandle)
Description copied from interface:Acknowledgeable
Handles anAcknowledgementRequest
identified by the passedacknowledgementLabel
issued by the Ditto backend for a received signal translated into this Acknowledgeable by invoking the passedacknowledgementHandle
consumer with a client sideAcknowledgementHandle
- if the passed acknowledgementLabel was present in the requested acknowledgements.- Specified by:
handleAcknowledgementRequest
in interfaceAcknowledgeable
- Parameters:
acknowledgementLabel
- theAcknowledgementLabel
which should be handled - if present - by the passedacknowledgementHandle
.acknowledgementHandle
- the consumer to invoke with aAcknowledgementHandle
used to send back anAcknowledgement
.
-
equals
public boolean equals(@Nullable java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-