Class AbstractConverter<S,​T>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractConverter​(java.lang.Class<? super S> sourceClass, java.lang.Class<? super 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.
      java.lang.Class<? super S> getSourceClass()
      Returns the source Class for this converter.
      java.lang.Class<? super T> getTargetClass()
      Returns the target Class for this converter.
      void loadConverters()
      Create and register converters with the Java object type conversion framework.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.ofbiz.base.conversion.Converter

        convert
    • Constructor Detail

      • AbstractConverter

        protected AbstractConverter​(java.lang.Class<? super S> sourceClass,
                                    java.lang.Class<? super T> targetClass)
    • Method Detail

      • loadConverters

        public void loadConverters()
        Description copied from interface: ConverterLoader
        Create and register converters with the Java object type conversion framework. If the converter extends one of the converter abstract classes, then the converter will register itself when an instance is created. Otherwise, call Converters.registerConverter(Converter) with the Converter instance.
        Specified by:
        loadConverters in interface ConverterLoader
      • 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
      • 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.
      • getSourceClass

        public java.lang.Class<? super S> 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<? super T> 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