T
- Target identifier typeC
- Message type@Beta public abstract class Message<T extends org.opendaylight.yangtools.concepts.WritableIdentifier,C extends Message<T,C>> extends Object implements org.opendaylight.yangtools.concepts.Immutable, Serializable
Request
and Response
.
Messages have a target and a sequence number. Sequence numbers are expected to be assigned monotonically on a per-target basis, hence two targets can observe the same sequence number.
This class includes explicit versioning for forward- and backward- compatibility of serialization format. This is achieved by using the serialization proxy pattern. Subclasses are in complete control of what proxy is used to serialize a particular object on the wire. This class can serve as an explicit version marker, hence no further action is necessary in the deserialization path.
For the serialization path an explicit call from the user is required to select the appropriate serialization
version. This is done via toVersion(ABIVersion)
method, which should return a copy of this object with
the requested ABI version recorded and should return the appropriate serialization proxy.
This workflow allows least disturbance across ABI versions, as all messages not affected by a ABI version bump will remain working with the same serialization format for the new ABI version.
Note that this class specifies the Immutable
contract, which means that all subclasses must follow this API
contract.
Modifier and Type | Method and Description |
---|---|
protected com.google.common.base.MoreObjects.ToStringHelper |
addToStringAttributes(com.google.common.base.MoreObjects.ToStringHelper toStringHelper)
Add attributes to the output of
toString() . |
protected abstract C |
cloneAsVersion(ABIVersion targetVersion)
Create a copy of this message which will serialize to a stream corresponding to the specified method.
|
long |
getSequence()
Get the logical sequence number.
|
T |
getTarget()
Get the target identifier for this message.
|
ABIVersion |
getVersion() |
String |
toString() |
C |
toVersion(ABIVersion toVersion)
Return a message which will end up being serialized in the specified
ABIVersion . |
protected Object |
writeReplace() |
@Nonnull public final T getTarget()
public final long getSequence()
@Nonnull public final ABIVersion getVersion()
@Nonnull public final C toVersion(@Nonnull ABIVersion toVersion)
ABIVersion
.toVersion
- Request ABIVersion
@Nonnull protected abstract C cloneAsVersion(@Nonnull ABIVersion targetVersion)
Message(Message, ABIVersion)
.targetVersion
- target ABI versionIllegalArgumentException
- if this message does not support the target ABI@Nonnull protected com.google.common.base.MoreObjects.ToStringHelper addToStringAttributes(@Nonnull com.google.common.base.MoreObjects.ToStringHelper toStringHelper)
toString()
. Subclasses wanting to contribute additional information
should override this method. Any null attributes will be omitted from the output.toStringHelper
- a MoreObjects.ToStringHelper
instanceMoreObjects.ToStringHelper
passed in as argumentNullPointerException
- if toStringHelper is nullprotected final Object writeReplace()
Copyright © 2019 OpenDaylight. All rights reserved.