Class Converters.PassThruConverter<S,​T>

  • All Implemented Interfaces:
    Converter<S,​T>
    Enclosing class:
    Converters

    protected static class Converters.PassThruConverter<S,​T>
    extends java.lang.Object
    implements Converter<S,​T>
    Pass thru converter used when the source and target java object types are the same. The convert method returns the source object.
    • Constructor Summary

      Constructors 
      Constructor Description
      PassThruConverter​(java.lang.Class<S> sourceClass, java.lang.Class<T> targetClass)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canConvert​(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
      Returns true if this object can convert sourceClass to targetClass.
      T convert​(java.lang.Class<? extends T> targetClass, S obj)
      Converts obj to T.
      T convert​(S obj)
      Converts obj to T.
      java.lang.Class<?> getSourceClass()
      Returns the source Class for this converter.
      java.lang.Class<?> getTargetClass()
      Returns the target Class for this converter.
      • Methods inherited from class java.lang.Object

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

      • PassThruConverter

        public PassThruConverter​(java.lang.Class<S> sourceClass,
                                 java.lang.Class<T> targetClass)
    • Method Detail

      • canConvert

        public boolean canConvert​(java.lang.Class<?> sourceClass,
                                  java.lang.Class<?> targetClass)
        Description copied from interface: Converter
        Returns true if this object can convert sourceClass to targetClass.

        Implementations can accomodate class hierarchy ranges by converting super classes or interfaces.

        Specified by:
        canConvert in interface Converter<S,​T>
        Parameters:
        sourceClass - The source Class
        targetClass - The target Class
        Returns:
        true if this object can convert sourceClass to targetClass.
      • convert

        public T convert​(java.lang.Class<? extends T> targetClass,
                         S obj)
                  throws ConversionException
        Description copied from interface: Converter
        Converts obj to T.
        Specified by:
        convert in interface Converter<S,​T>
        Parameters:
        targetClass - The Class to convert to
        obj - The source Object to convert
        Returns:
        The converted Object
        Throws:
        ConversionException
      • getSourceClass

        public java.lang.Class<?> getSourceClass()
        Description copied from interface: Converter
        Returns the source Class for this converter.
        Specified by:
        getSourceClass in interface Converter<S,​T>
        Returns:
        The source Class for this converter
      • getTargetClass

        public java.lang.Class<?> getTargetClass()
        Description copied from interface: Converter
        Returns the target Class for this converter.
        Specified by:
        getTargetClass in interface Converter<S,​T>
        Returns:
        The target Class for this converter