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 aSerializationContext
. TheImmutableSerializationContext
is a super-interface that contains strictly read-only methods while its descendantSerializationContext
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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description boolean
canMarshall(Class<?> javaClass)
Checks if the given type (message or enum) can be marshalled.boolean
canMarshall(String fullTypeName)
Checks if the given type (message or enum) can be marshalled.Configuration
getConfiguration()
Get the (immutable) configuration object that was used when creating this context.GenericDescriptor
getDescriptorByName(String fullTypeName)
Obtains the descriptor associated with a type name.GenericDescriptor
getDescriptorByTypeId(Integer typeId)
Obtains the descriptor associated with a numeric type id.EnumDescriptor
getEnumDescriptor(String fullTypeName)
Map<String,FileDescriptor>
getFileDescriptors()
Obtain the currently registered file descriptors.Map<String,GenericDescriptor>
getGenericDescriptors()
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.Descriptor
getMessageDescriptor(String fullTypeName)
Integer
getTypeIdByName(String fullTypeName)
Deprecated.since 4.2.2, to be removed in 5, replaced bygetDescriptorByName(fullTypeName).getTypeId()
String
getTypeNameById(Integer typeId)
Deprecated.since 4.2.2, to be removed in 5, replaced bygetDescriptorByTypeId(typeId).getFullName()
-
-
-
Method Detail
-
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
Descriptor getMessageDescriptor(String fullTypeName)
- Throws:
IllegalArgumentException
- if the descriptor is not found or is not a message
-
getEnumDescriptor
EnumDescriptor getEnumDescriptor(String fullTypeName)
- Throws:
IllegalArgumentException
- if the descriptor is not found or is not an enum
-
canMarshall
boolean canMarshall(Class<?> javaClass)
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
boolean canMarshall(String fullTypeName)
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
-
getMarshaller
<T> BaseMarshaller<T> getMarshaller(String fullTypeName)
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
<T> BaseMarshaller<T> getMarshaller(Class<T> clazz)
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 String getTypeNameById(Integer typeId)
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 Integer getTypeIdByName(String fullTypeName)
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
GenericDescriptor getDescriptorByTypeId(Integer typeId)
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
GenericDescriptor getDescriptorByName(String fullTypeName)
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
-
-