Package org.infinispan.protostream
Interface ImmutableSerializationContext
- All Known Subinterfaces:
SerializationContext
- All Known Implementing Classes:
SerializationContextImpl
public interface ImmutableSerializationContext
A repository of Protobuf type definitions and their marshallers. All marshalling operations happen in the context of
a
SerializationContext
. The ImmutableSerializationContext
is a super-interface that contains strictly
read-only methods while its descendant SerializationContext
provides methods to mutate the context.
NOTE: While this interface does not provide mutator methods that does not actually mean its state is really
immutable. It may be mutated through SerializationContext
interface.
- Since:
- 4.0
- Author:
- [email protected]
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canMarshall
(Class<?> javaClass) Checks if the given type (message or enum) can be marshalled.boolean
canMarshall
(Object object) Checks if the given instance can be marshalled.boolean
canMarshall
(String fullTypeName) Checks if the given type (message or enum) can be marshalled.Get the (immutable) configuration object that was used when creating this context.getDescriptorByName
(String fullTypeName) Obtains the descriptor associated with a type name.getDescriptorByTypeId
(Integer typeId) Obtains the descriptor associated with a numeric type id.getEnumDescriptor
(String fullTypeName) Obtain the currently registered file descriptors.Obtain the currently registered type descriptors.<T> BaseMarshaller<T>
getMarshaller
(Class<T> clazz) Obtains the marshaller associated with a Java type.<T> BaseMarshaller<T>
getMarshaller
(String fullTypeName) Obtains the marshaller associated with a Protobuf type name.<T> BaseMarshaller<T>
getMarshaller
(T object) Obtains the marshaller associated with a given instance.getMessageDescriptor
(String fullTypeName) getTypeIdByName
(String fullTypeName) Deprecated.getTypeNameById
(Integer typeId) Deprecated.since 4.2.2, to be removed in 5, replaced bygetDescriptorByTypeId(typeId).getFullName()
-
Method Details
-
getConfiguration
Configuration getConfiguration()Get the (immutable) configuration object that was used when creating this context. -
getFileDescriptors
Map<String,FileDescriptor> getFileDescriptors()Obtain the currently registered file descriptors.- Returns:
- an immutable copy of the internal map of descriptors
-
getGenericDescriptors
Map<String,GenericDescriptor> getGenericDescriptors()Obtain the currently registered type descriptors.- Returns:
- an immutable copy of the internal map of descriptors
-
getMessageDescriptor
- Throws:
IllegalArgumentException
- if the descriptor is not found or is not a message
-
getEnumDescriptor
- Throws:
IllegalArgumentException
- if the descriptor is not found or is not an enum
-
canMarshall
Checks if the given type (message or enum) can be marshalled. This checks that a marshaller was registered for it.- Parameters:
javaClass
- the object or enum class to check- Returns:
true
if a marshaller exists,false
otherwise
-
canMarshall
Checks if the given type (message or enum) can be marshalled. This checks that the Protobuf type was defined and a marshaller was registered for it.- Parameters:
fullTypeName
- the fully qualified name of the Protobuf definition to check- Returns:
true
if a marshaller exists,false
otherwise
-
canMarshall
Checks if the given instance can be marshalled.- Parameters:
object
- the instance- Returns:
true
if a marshaller exists,false
otherwise
-
getMarshaller
Obtains the marshaller associated with a given instance.- Parameters:
object
- the instance- Returns:
- the marshaller
- Throws:
IllegalArgumentException
- if the given instance does not have a suitable marshaller registered
-
getMarshaller
Obtains the marshaller associated with a Protobuf type name.- Parameters:
fullTypeName
- the type name- Returns:
- the marshaller
- Throws:
IllegalArgumentException
- if the given type name is not known to this context
-
getMarshaller
Obtains the marshaller associated with a Java type.- Parameters:
clazz
- the class- Returns:
- the marshaller
- Throws:
IllegalArgumentException
- if the given Java type is not known to this context
-
getTypeNameById
Deprecated.since 4.2.2, to be removed in 5, replaced bygetDescriptorByTypeId(typeId).getFullName()
Obtains the Protobuf type name associated with a numeric type id.- Parameters:
typeId
- the numeric type id- Returns:
- the fully qualified type name
- Throws:
IllegalArgumentException
- if the given type id is not known to this context
-
getTypeIdByName
Deprecated.since 4.2.2, to be removed in 5, replaced bygetDescriptorByName(fullTypeName).getTypeId()
Obtains the associated numeric type id for a Protobuf type name, if a numeric id was defined.- Parameters:
fullTypeName
- the fully qualified type name- Returns:
- the type id or
null
if no type id is associated with the type - Throws:
IllegalArgumentException
- if the given type name is not known to this context
-
getDescriptorByTypeId
Obtains the descriptor associated with a numeric type id.- Parameters:
typeId
- the numeric type id- Returns:
- the descriptor
- Throws:
IllegalArgumentException
- if the given type id is not known to this context
-
getDescriptorByName
Obtains the descriptor associated with a type name.- Parameters:
fullTypeName
- the fully qualified type name- Returns:
- the descriptor
- Throws:
IllegalArgumentException
- if the given type name is not known to this context
-
getDescriptorByName(fullTypeName).getTypeId()