public class AtomContextProvider extends java.lang.Object implements BaggageProvider<AtomContext>
BaggageProvider for AtomContext, a minimal BaggageContext based on atoms and lexicographic merge.
| Constructor and Description |
|---|
AtomContextProvider() |
| Modifier and Type | Method and Description |
|---|---|
AtomContext |
branch(AtomContext from)
Create and return a copy of
from. |
AtomContext |
deserialize(byte[] serialized,
int offset,
int length)
Deserialize the provided serialized baggage representation.
|
AtomContext |
deserialize(java.nio.ByteBuffer buf)
Deserialize the provided serialized baggage representation.
|
void |
discard(AtomContext baggageContext)
Discards
baggage. |
boolean |
isValid(BaggageContext baggageContext) |
AtomContext |
join(AtomContext left,
AtomContext right)
Merge the contents of
left and right and return as baggage. |
AtomContext |
newInstance() |
byte[] |
serialize(AtomContext baggageContext)
Serialize the provided baggage instance to its byte representation.
|
byte[] |
serialize(AtomContext baggageContext,
int maximumSerializedSize)
Serialize the provided baggage instance to its byte representation and trim the baggage so that its serialized
size is
<= maximumSerializedSize. |
public boolean isValid(BaggageContext baggageContext)
isValid in interface BaggageProvider<AtomContext>baggageContext - a BaggageContext to testbaggage is an instance of B or if baggage is null.public AtomContext newInstance()
newInstance in interface BaggageProvider<AtomContext>B, which may be null to indicate an empty baggagepublic void discard(AtomContext baggageContext)
BaggageProviderbaggage. If this TransitLayer performs anything like reference counting, then this method
is where decrementing reference counts would happen.discard in interface BaggageProvider<AtomContext>baggageContext - a baggage instancepublic AtomContext branch(AtomContext from)
BaggageProviderfrom. If this TransitLayer performs anything like reference counting,
then this method might just return from while incrementing reference counts.
This method might create a new instance of B and might even modify the contents of frombranch in interface BaggageProvider<AtomContext>from - a baggage instance, possibly nullfrom, possibly nullpublic AtomContext join(AtomContext left, AtomContext right)
BaggageProviderleft and right and return as baggage. left and
right should be treated as discarded (or reused) after this method call.join in interface BaggageProvider<AtomContext>left - a baggage instance, possibly nullright - a baggage instance, possibly nullleft and rightpublic AtomContext deserialize(byte[] serialized, int offset, int length)
BaggageProviderdeserialize in interface BaggageProvider<AtomContext>serialized - a serialized baggageoffset - offset into the array where the baggage bytes beginlength - lenft of the baggage bytespublic AtomContext deserialize(java.nio.ByteBuffer buf)
BaggageProviderdeserialize in interface BaggageProvider<AtomContext>buf - a serialized baggagepublic byte[] serialize(AtomContext baggageContext)
BaggageProvider#branch(Baggage) is also being called prior to serialization.serialize in interface BaggageProvider<AtomContext>baggageContext - a baggage instance to serialize, possibly nullbaggage, which might be null or an empty byte arraypublic byte[] serialize(AtomContext baggageContext, int maximumSerializedSize)
BaggageProvider<= maximumSerializedSize. This method should behave as though #branch(Baggage) is also
being called prior to serialization.serialize in interface BaggageProvider<AtomContext>baggageContext - a baggage instance to serialize, possibly nullmaximumSerializedSize - the maximum size in bytes of the serialized baggage.baggage, which might be null or an empty byte array