Class PersistRegistry
- java.lang.Object
-
- PersistRegistry
-
public class PersistRegistry extends Object
A registry of PersistCodec instances for a particular protocol.
-
-
Constructor Summary
Constructors Constructor Description PersistRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S,T extends S>
PersistCodec<? super S,? extends T,? extends com.google.protobuf.Message>getCodec(Class<S> upperBound, Class<T> lowerBound)
Get the codec for this protocol that encodes instances of a particular type (or subclasses) and decodes to another type (or a subclass).<T> PersistCodec<T,? extends T,? extends com.google.protobuf.Message>
getCodec(Class<T> type)
Get the codec for this protocol that encodes a particular type (or subclasses) and decodes to that same type (or a subclass).<S,T extends S>
voidregisterCodec(Class<S> upperTypeBound, Class<T> lowerTypeBound, PersistCodec<S,T,?> codec)
Register a codec.
-
-
-
Method Detail
-
getCodec
public <T> PersistCodec<T,? extends T,? extends com.google.protobuf.Message> getCodec(Class<T> type)
Get the codec for this protocol that encodes a particular type (or subclasses) and decodes to that same type (or a subclass).- Parameters:
type
- the type to retrieve a codec for- Returns:
- an appropriate codec for that type, or
null
if no suitable codec exists
-
getCodec
public <S,T extends S> PersistCodec<? super S,? extends T,? extends com.google.protobuf.Message> getCodec(Class<S> upperBound, Class<T> lowerBound)
Get the codec for this protocol that encodes instances of a particular type (or subclasses) and decodes to another type (or a subclass).- Parameters:
upperBound
- the type that the encoder will acceptlowerBound
- the type that the decoder will return- Returns:
- an appropriate codec for that type, or
null
if no suitable codec exists
-
registerCodec
public <S,T extends S> void registerCodec(Class<S> upperTypeBound, Class<T> lowerTypeBound, PersistCodec<S,T,?> codec)
Register a codec. Called by individual protocols. Warning: not threadsafe. Callers should ensure that registration is protected by external synchronization.- Parameters:
upperTypeBound
- the least-specific type supported by the codeclowerTypeBound
- the most-specific type supported by the codeccodec
- the codec itself
-
-