Class SerdeProperties
- java.lang.Object
-
- com.solace.serdes.common.resolver.config.BaseProperties
-
- com.solace.serdes.common.SerdeProperties
-
- Direct Known Subclasses:
AvroProperties
public class SerdeProperties extends BaseProperties
A class for configuring common properties. This is used byAbstractSerializerandAbstractDeserializer.- See Also:
AbstractSerializer,AbstractDeserializer
-
-
Field Summary
Fields Modifier and Type Field Description static StringDESERIALIZED_TYPEAn optional property when set explicitly checks if the deserialized type matches this property.static StringEXPLICIT_SCHEMA_IDProperty key for setting an explicit schema ID to be used during serialization.static StringSCHEMA_HEADER_IDENTIFIERSProperty key for setting one or more schema header identifiers to be encoded in the serializer headers.static StringSCHEMA_RESOLVERProperty key for specifying a custom schema resolver implementation.
-
Constructor Summary
Constructors Constructor Description SerdeProperties()Constructs a new SerdeProperties instance with default properties.SerdeProperties(Map<String,?> map)Constructs a new SerdeProperties instance with default properties then applies properties from the passed in map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>getDefaults()Gets a copy of the default SERDE properties.Class<?>getDeserializedType()Retrieves the expected Deserialized type as specified in the configuration.Optional<Long>getExplicitSchemaId()Gets the Explicit SchemeId.Set<SchemaHeaderId>getSchemaHeaderIdentifiers()Retrieves the schema header identifiers as specified in the configuration.Class<?>getSchemaResolverClass()Retrieves a SchemaResolver for the specified schema type.-
Methods inherited from class com.solace.serdes.common.resolver.config.BaseProperties
getConfig
-
-
-
-
Field Detail
-
EXPLICIT_SCHEMA_ID
public static final String EXPLICIT_SCHEMA_ID
Property key for setting an explicit schema ID to be used during serialization. Not used in deserialization.This property allows overriding the schema ID provided by the schema registry. When set, the serializer will use this explicit schema ID instead of the one obtained from the registry.
The value should be a non-negative
Numberor aStringthat can be parsed as a non-negative long (0 or positive). If set to a negativeNumberor unparsableString,AbstractSerializer.configure(java.util.Map)will throw anIllegalStateException.If this property is not set or is set to null, the serializer will use the schema ID provided by the schema registry.
Example usage:
// Using a Number properties.put(EXPLICIT_SCHEMA_ID, 42L); // Using a String properties.put(EXPLICIT_SCHEMA_ID, "42");
- See Also:
- Constant Field Values
-
SCHEMA_RESOLVER
public static final String SCHEMA_RESOLVER
Property key for specifying a custom schema resolver implementation.This property allows the user to provide a custom implementation of the SchemaResolver interface, which is responsible for resolving schema information during serialization and deserialization processes.
The value associated with this key should be either:
- A
Stringof a qualified class name of a class implementing the SchemaResolver interface - An
Classobject of a class implementing the SchemaResolver interface
Make sure the target class must have a public no-argument constructor.
Example usage. All these will have equivalent functionality.
// Using a class name properties.put(SCHEMA_RESOLVER, "com.example.CustomSchemaResolver"); // Using an Class object properties.put(SCHEMA_RESOLVER, CustomSchemaResolver.class);
The specified schema resolver will be used for all schema resolution operations, potentially overriding the default behavior of schema lookup and caching.
- See Also:
SchemaResolver, Constant Field Values
- A
-
DESERIALIZED_TYPE
public static final String DESERIALIZED_TYPE
An optional property when set explicitly checks if the deserialized type matches this property.The value associated with this key should be either:
nullwhen no checking is wanted (Default)- A
Stringof a qualified class name of a class implementing the SpecificRecord interface - An
Classobject of a class implementing the SchemaResolver interface
Example usage. All these will have equivalent functionality.
// Using a class name properties.put(DESERIALIZED_TYPE, "com.example.CustomSpecificRecord"); // Using an Class object properties.put(DESERIALIZED_TYPE, CustomSpecificRecord.class);
- See Also:
- Constant Field Values
-
SCHEMA_HEADER_IDENTIFIERS
public static final String SCHEMA_HEADER_IDENTIFIERS
Property key for setting one or more schema header identifiers to be encoded in the serializer headers.NOTE: This property has no impact on deserializers.
The value associated with this key should be either:
- A
Stringof aSchemaHeaderIdenum constant - A
SchemaHeaderIdenum constant - An
EnumSet<SchemaHeaderId>for multiple identifiers
The default value is set to:
SchemaHeaderId.SCHEMA_ID.Example usage:
// Using a String for a single identifier properties.put(SCHEMA_HEADER_IDENTIFIERS, "SCHEMA_ID_STRING"); // Using an Enum constant for a single identifier properties.put(SCHEMA_HEADER_IDENTIFIERS, SchemaHeaderId.SCHEMA_ID_STRING); // Using an EnumSet for multiple identifiers properties.put(SCHEMA_HEADER_IDENTIFIERS, EnumSet.of(SchemaHeaderId.SCHEMA_ID, SchemaHeaderId.SCHEMA_ID_STRING));
- See Also:
SchemaHeaderId, Constant Field Values
- A
-
-
Method Detail
-
getDefaults
public static Map<String,Object> getDefaults()
Gets a copy of the default SERDE properties.- Returns:
- The default set properties.
-
getExplicitSchemaId
public Optional<Long> getExplicitSchemaId()
Gets the Explicit SchemeId.- Returns:
- An Optional containing the explicit schema ID if it was set, or an empty Optional if no explicit schema ID was provided.
- Throws:
IllegalStateException- when the keySerdeProperties.EXPLICIT_SCHEMA_IDmatches one of the following cases:- The value is not a
Stringor aNumber - The value is a
String, but is not parsable as a long - The value is negative.
- The value is not a
-
getSchemaResolverClass
public Class<?> getSchemaResolverClass()
Retrieves a SchemaResolver for the specified schema type.This method attempts to get an instance of a SchemaResolver that can handle the given schema type.
The
SCHEMA_RESOLVERkey in the configuration can be:- A fully qualified class name (String) of a SchemaResolver implementation
- A Class object of a SchemaResolver implementation
- Returns:
- A SchemaResolver instance that can handle the specified schema type.
- Throws:
IllegalStateException- if:- No SchemaResolver is found for the
SCHEMA_RESOLVERkey - The class specified by the
SCHEMA_RESOLVERkey is not found - The object specified by the
SCHEMA_RESOLVERkey is neither a String, nor Class
- No SchemaResolver is found for the
- See Also:
SchemaResolver
-
getDeserializedType
public Class<?> getDeserializedType()
Retrieves the expected Deserialized type as specified in the configuration. Returns null when not set.This method gets the Deserialized type that was configured using the
DESERIALIZED_TYPEproperty.The
DESERIALIZED_TYPEkey in the configuration can be:nullwhen no checking is wanted (Default)- A fully qualified class name (String) of a SpecificRecord implementation
- A Class object of a SpecificRecord implementation
- Returns:
- The Class object of the configured deserialized type.
- Throws:
IllegalStateException- if:- The class specified by the
DESERIALIZED_TYPEkey is not found - The object specified by the
DESERIALIZED_TYPEkey is neither a String, nor Class
- The class specified by the
-
getSchemaHeaderIdentifiers
public Set<SchemaHeaderId> getSchemaHeaderIdentifiers()
Retrieves the schema header identifiers as specified in the configuration.This method gets the schema header identifiers that were configured using the
SCHEMA_HEADER_IDENTIFIERSproperty.The
SCHEMA_HEADER_IDENTIFIERSkey in the configuration can be:- A
Stringof aSchemaHeaderIdenum constant - A
SchemaHeaderIdenum constant - An
EnumSet<SchemaHeaderId>for multiple identifiers
- Returns:
- The set of schema header identifiers.
- Throws:
IllegalStateException- if the value associated with the key is null or of an incompatible type.- See Also:
SCHEMA_HEADER_IDENTIFIERS
- A
-
-