public class NoOpBaggageContextProvider extends java.lang.Object implements BaggageProvider<BaggageContext>
BaggageProvider
implementation that always just returns null.Constructor and Description |
---|
NoOpBaggageContextProvider() |
Modifier and Type | Method and Description |
---|---|
BaggageContext |
branch(BaggageContext from)
Create and return a copy of
from . |
BaggageContext |
deserialize(byte[] serialized,
int offset,
int length)
Deserialize the provided serialized baggage representation.
|
BaggageContext |
deserialize(java.nio.ByteBuffer buf)
Deserialize the provided serialized baggage representation.
|
void |
discard(BaggageContext baggage)
Discards
baggage . |
boolean |
isValid(BaggageContext baggage) |
BaggageContext |
join(BaggageContext left,
BaggageContext right)
Merge the contents of
left and right and return as baggage. |
BaggageContext |
newInstance() |
byte[] |
serialize(BaggageContext baggage)
Serialize the provided baggage instance to its byte representation.
|
byte[] |
serialize(BaggageContext baggage,
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 baggage)
isValid
in interface BaggageProvider<BaggageContext>
baggage
- a BaggageContext to testbaggage
is an instance of B
or if baggage is null.public BaggageContext newInstance()
newInstance
in interface BaggageProvider<BaggageContext>
B
, which may be null to indicate an empty baggagepublic void discard(BaggageContext baggage)
BaggageProvider
baggage
. If this TransitLayer performs anything like reference counting, then this method
is where decrementing reference counts would happen.discard
in interface BaggageProvider<BaggageContext>
baggage
- a baggage instancepublic BaggageContext branch(BaggageContext from)
BaggageProvider
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
branch
in interface BaggageProvider<BaggageContext>
from
- a baggage instance, possibly nullfrom
, possibly nullpublic BaggageContext join(BaggageContext left, BaggageContext right)
BaggageProvider
left
and right
and return as baggage. left
and
right
should be treated as discarded (or reused) after this method call.join
in interface BaggageProvider<BaggageContext>
left
- a baggage instance, possibly nullright
- a baggage instance, possibly nullleft
and right
public BaggageContext deserialize(byte[] serialized, int offset, int length)
BaggageProvider
deserialize
in interface BaggageProvider<BaggageContext>
serialized
- a serialized baggageoffset
- offset into the array where the baggage bytes beginlength
- lenft of the baggage bytespublic BaggageContext deserialize(java.nio.ByteBuffer buf)
BaggageProvider
deserialize
in interface BaggageProvider<BaggageContext>
buf
- a serialized baggagepublic byte[] serialize(BaggageContext baggage)
BaggageProvider
#branch(Baggage)
is also being called prior to serialization.serialize
in interface BaggageProvider<BaggageContext>
baggage
- a baggage instance to serialize, possibly nullbaggage
, which might be null or an empty byte arraypublic byte[] serialize(BaggageContext baggage, int maximumSerializedSize)
BaggageProvider
<= maximumSerializedSize
. This method should behave as though #branch(Baggage)
is also
being called prior to serialization.serialize
in interface BaggageProvider<BaggageContext>
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