Package com.upokecenter.cbor
Class CBORTypeMapper
- java.lang.Object
-
- com.upokecenter.cbor.CBORTypeMapper
-
public final class CBORTypeMapper extends java.lang.ObjectHolds converters to customize the serialization and deserialization behavior ofCBORObject.FromObjectandCBORObject#ToObject, as well as type filters forToObject.
-
-
Constructor Summary
Constructors Constructor Description CBORTypeMapper()Initializes a new instance of theCBORTypeMapperclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> CBORTypeMapperAddConverter(java.lang.reflect.Type type, ICBORConverter<T> converter)Registers an object that converts objects of a given type to CBOR objects (called a CBOR converter).CBORTypeMapperAddTypeName(java.lang.String name)Adds the fully qualified name of a Java or.NET type for use in type matching.CBORTypeMapperAddTypePrefix(java.lang.String prefix)Adds a prefix of a Java or.NET type for use in type matching.booleanFilterTypeName(java.lang.String typeName)Returns whether the given Java or.NET type name fits the filters given in this mapper.
-
-
-
Constructor Detail
-
CBORTypeMapper
public CBORTypeMapper()
Initializes a new instance of theCBORTypeMapperclass.
-
-
Method Detail
-
AddConverter
public <T> CBORTypeMapper AddConverter(java.lang.reflect.Type type, ICBORConverter<T> converter)
Registers an object that converts objects of a given type to CBOR objects (called a CBOR converter).- Type Parameters:
T- Must be the same as the "type" parameter.- Parameters:
type- A Type object specifying the type that the converter converts to CBOR objects.converter- The parameterconverteris an ICBORConverter object.- Returns:
- This object.
- Throws:
java.lang.NullPointerException- The parametertypeorconverteris null.java.lang.IllegalArgumentException- Converter doesn't contain a proper ToCBORObject method".
-
FilterTypeName
public boolean FilterTypeName(java.lang.String typeName)
Returns whether the given Java or.NET type name fits the filters given in this mapper.- Parameters:
typeName- The fully qualified name of a Java or.NET class (e.g.,java.math.BigIntegerorSystem.Globalization.CultureInfo).- Returns:
- Either
trueif the given Java or.NET type name fits the filters given in this mapper, orfalseotherwise.
-
AddTypePrefix
public CBORTypeMapper AddTypePrefix(java.lang.String prefix)
Adds a prefix of a Java or.NET type for use in type matching. A type matches a prefix if its fully qualified name is or begins with that prefix, using codepoint-by-codepoint (case-sensitive) matching.- Parameters:
prefix- The prefix of a Java or.NET type (e.g., `java.math.` or `System.Globalization`).- Returns:
- This object.
- Throws:
java.lang.NullPointerException- The parameterprefixis null.java.lang.IllegalArgumentException- The parameterprefixis empty.
-
AddTypeName
public CBORTypeMapper AddTypeName(java.lang.String name)
Adds the fully qualified name of a Java or.NET type for use in type matching.- Parameters:
name- The fully qualified name of a Java or.NET class (e.g.,java.math.BigIntegerorSystem.Globalization.CultureInfo).- Returns:
- This object.
- Throws:
java.lang.NullPointerException- The parameternameis null.java.lang.IllegalArgumentException- The parameternameis empty.
-
-