Class GenericUnmarshaller<T>

java.lang.Object
org.openhab.core.config.core.xml.util.GenericUnmarshaller<T>
Type Parameters:
T - the result type of the conversion
All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher
Direct Known Subclasses:
ConfigDescriptionConverter, ConfigDescriptionParameterConverter, ConfigDescriptionParameterGroupConverter, FilterCriteriaConverter, NodeAttributesConverter, NodeListConverter, NodeValueConverter

@NonNullByDefault public abstract class GenericUnmarshaller<T> extends Object implements com.thoughtworks.xstream.converters.Converter
The GenericUnmarshaller is an abstract implementation of the XStream Converter interface used to convert XML tags within an XML document into its according objects.

Hint: This class only supports unmarshalling functionality.

Author:
Michael Grammling - Initial contribution
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of this class with the specified parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    canConvert(@Nullable Class paramClass)
     
    Returns the class of the result type
    final void
    marshal(@Nullable Object value, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
     
    protected static String
    requireNonEmpty(@Nullable String string, String message)
    Checks that the specified string is not null and not empty and throws a customized ConversionException if it is.
    protected static Object
    requireNonNull(@Nullable Object object, String message)
    Checks that the specified object is not null and throws a customized ConversionException if it is.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.thoughtworks.xstream.converters.Converter

    unmarshal
  • Constructor Details

    • GenericUnmarshaller

      public GenericUnmarshaller(Class<T> clazz)
      Creates a new instance of this class with the specified parameter.
      Parameters:
      clazz - the class of the result type (must not be null)
  • Method Details

    • getResultType

      public Class<?> getResultType()
      Returns the class of the result type
      Returns:
      the class of the result type
    • canConvert

      public final boolean canConvert(@Nullable Class paramClass)
      Specified by:
      canConvert in interface com.thoughtworks.xstream.converters.ConverterMatcher
    • marshal

      public final void marshal(@Nullable Object value, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
      Specified by:
      marshal in interface com.thoughtworks.xstream.converters.Converter
    • requireNonNull

      protected static Object requireNonNull(@Nullable Object object, String message)
      Checks that the specified object is not null and throws a customized ConversionException if it is.
      Parameters:
      object - the object to check for nullity
      message - detail message to be used in the event that a ConversionException is thrown
      Returns:
      object if not null
      Throws:
      com.thoughtworks.xstream.converters.ConversionException - if object is null
    • requireNonEmpty

      protected static String requireNonEmpty(@Nullable String string, String message)
      Checks that the specified string is not null and not empty and throws a customized ConversionException if it is.
      Parameters:
      string - the string to check for nullity and emptiness
      message - detail message to be used in the event that a ConversionException is thrown
      Returns:
      string if not null and not empty
      Throws:
      com.thoughtworks.xstream.converters.ConversionException - if string is null or empty