ma.glasnost.orika.converter.builtin
Class PassThroughConverter

java.lang.Object
  extended by ma.glasnost.orika.CustomConverter<Object,Object>
      extended by ma.glasnost.orika.converter.builtin.PassThroughConverter
All Implemented Interfaces:
Converter<Object,Object>, MappedTypePair<Object,Object>

public class PassThroughConverter
extends CustomConverter<Object,Object>

PassThroughConverter allows configuration of a number of specific types which should be passed through (as-is) without creating a mapped copy.

This allows you to declare your own set of types which should be treated by Orika as if they were in the set of immutable types.

Author:
matt.deboer@gmail.com

Field Summary
 
Fields inherited from class ma.glasnost.orika.CustomConverter
destinationType, mapperFacade, sourceType
 
Constructor Summary
PassThroughConverter(Type... types)
          Constructs a new PassThroughConverter configured to treat the provided list of types as immutable.
 
Method Summary
 boolean canConvert(Type<?> sourceType, Type<?> destinationType)
          Answers whether this converter can be used to handle the conversion of sourceType to destinationType.
 Object convert(Object source, Type<? extends Object> destinationType)
          Perform the conversion of source into a new instance of destinationType.
 
Methods inherited from class ma.glasnost.orika.CustomConverter
getAType, getBType, setMapperFacade, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PassThroughConverter

public PassThroughConverter(Type... types)
Constructs a new PassThroughConverter configured to treat the provided list of types as immutable.

Parameters:
types - one or more types that should be treated as immutable
Method Detail

canConvert

public boolean canConvert(Type<?> sourceType,
                          Type<?> destinationType)
Description copied from interface: Converter
Answers whether this converter can be used to handle the conversion of sourceType to destinationType.

Specified by:
canConvert in interface Converter<Object,Object>
Overrides:
canConvert in class CustomConverter<Object,Object>
Returns:

convert

public Object convert(Object source,
                      Type<? extends Object> destinationType)
Description copied from interface: Converter
Perform the conversion of source into a new instance of destinationType.

Parameters:
source - the source object to be converted
destinationType - the destination type to produce
Returns:
a new instance of destinationType


Copyright © 2013 Glasnost. All Rights Reserved.