public interface BaggageProvider<B extends BaggageContext>
A BaggageProvider
provides an implementation of BaggageContext
objects. Manipulation of
BaggageContext
objects is primarily done through BaggageProvider
methods.
Modifier and Type | Method and Description |
---|---|
B |
branch(B from)
Create and return a copy of
from . |
B |
deserialize(byte[] serialized,
int offset,
int length)
Deserialize the provided serialized baggage representation.
|
B |
deserialize(java.nio.ByteBuffer buf)
Deserialize the provided serialized baggage representation.
|
void |
discard(B baggage)
Discards
baggage . |
boolean |
isValid(BaggageContext baggage) |
B |
join(B left,
B right)
Merge the contents of
left and right and return as baggage. |
B |
newInstance() |
byte[] |
serialize(B baggage)
Serialize the provided baggage instance to its byte representation.
|
byte[] |
serialize(B baggage,
int maximumSerializedSize)
Serialize the provided baggage instance to its byte representation and trim the baggage so that its serialized
size is
<= maximumSerializedSize . |
boolean isValid(BaggageContext baggage)
baggage
- a BaggageContext to testbaggage
is an instance of B
or if baggage is null.B newInstance()
B
, which may be null to indicate an empty baggagevoid discard(B baggage)
baggage
. If this TransitLayer performs anything like reference counting, then this method
is where decrementing reference counts would happen.baggage
- a baggage instanceB branch(B from)
from
. 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 from
from
- a baggage instance, possibly nullfrom
, possibly nullB join(B left, B right)
left
and right
and return as baggage. left
and
right
should be treated as discarded (or reused) after this method call.left
- a baggage instance, possibly nullright
- a baggage instance, possibly nullleft
and right
B deserialize(byte[] serialized, int offset, int length)
serialized
- a serialized baggageoffset
- offset into the array where the baggage bytes beginlength
- lenft of the baggage bytesB deserialize(java.nio.ByteBuffer buf)
buf
- a serialized baggagebyte[] serialize(B baggage)
#branch(Baggage)
is also being called prior to serialization.baggage
- a baggage instance to serialize, possibly nullbaggage
, which might be null or an empty byte arraybyte[] serialize(B baggage, int maximumSerializedSize)
<= maximumSerializedSize
. This method should behave as though #branch(Baggage)
is also
being called prior to serialization.baggage
- 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