Class CBORTypeMapper


  • public final class CBORTypeMapper
    extends java.lang.Object
    Holds converters to customize the serialization and deserialization behavior of CBORObject.FromObject and CBORObject#ToObject, as well as type filters for ToObject.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <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).
      CBORTypeMapper AddTypeName​(java.lang.String name)
      Adds the fully qualified name of a Java or.NET type for use in type matching.
      CBORTypeMapper AddTypePrefix​(java.lang.String prefix)
      Adds a prefix of a Java or.NET type for use in type matching.
      boolean FilterTypeName​(java.lang.String typeName)
      Returns whether the given Java or.NET type name fits the filters given in this mapper.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CBORTypeMapper

        public CBORTypeMapper()
        Initializes a new instance of the CBORTypeMapper class.
    • 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 parameter converter is an ICBORConverter object.
        Returns:
        This object.
        Throws:
        java.lang.NullPointerException - The parameter type or converter is 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.BigInteger or System.Globalization.CultureInfo).
        Returns:
        Either true if the given Java or.NET type name fits the filters given in this mapper, or false otherwise.
      • 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 parameter prefix is null.
        java.lang.IllegalArgumentException - The parameter prefix is 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.BigInteger or System.Globalization.CultureInfo).
        Returns:
        This object.
        Throws:
        java.lang.NullPointerException - The parameter name is null.
        java.lang.IllegalArgumentException - The parameter name is empty.