org.apache.commons.convert
Class Converters.PassThruConverter<S,T>

java.lang.Object
  extended by org.apache.commons.convert.Converters.PassThruConverter<S,T>
All Implemented Interfaces:
Converter<S,T>
Enclosing class:
Converters

protected static class Converters.PassThruConverter<S,T>
extends Object
implements Converter<S,T>

Pass-through converter used when the source and target java object types are the same. The convert method returns the source object.


Constructor Summary
Converters.PassThruConverter(Class<S> sourceClass, Class<T> targetClass)
           
 
Method Summary
 boolean canConvert(Class<?> sourceClass, Class<?> targetClass)
          Returns true if this object can convert sourceClass to targetClass.
 T convert(S obj)
          Converts obj to T.
 Class<?> getSourceClass()
          Returns the source Class for this converter.
 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

Converters.PassThruConverter

public Converters.PassThruConverter(Class<S> sourceClass,
                                    Class<T> targetClass)
Method Detail

canConvert

public boolean canConvert(Class<?> sourceClass,
                          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(S obj)
          throws ConversionException
Description copied from interface: Converter
Converts obj to T.

Specified by:
convert in interface Converter<S,T>
Parameters:
obj - The source Object to convert
Returns:
The converted Object
Throws:
ConversionException

getSourceClass

public 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 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


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.