ma.glasnost.orika.converter
Class BidirectionalConverter<S,D>

java.lang.Object
  extended by ma.glasnost.orika.CustomConverter<Object,Object>
      extended by ma.glasnost.orika.converter.BidirectionalConverter<S,D>
Type Parameters:
S -
D -
All Implemented Interfaces:
Converter<Object,Object>, MappedTypePair<Object,Object>
Direct Known Subclasses:
DateAndTimeConverters.CalendarToXmlGregorianCalendarConverter, DateAndTimeConverters.DateToCalendarConverter, DateAndTimeConverters.DateToXmlGregorianCalendarConverter, DateAndTimeConverters.LongToCalendarConverter, DateAndTimeConverters.LongToDateConverter, DateAndTimeConverters.LongToSqlDateConverter, DateAndTimeConverters.LongToTimeConverter, DateAndTimeConverters.LongToXmlGregorianCalendarConverter, DateToStringConverter, NumericConverters.BigDecimalToDoubleConverter, NumericConverters.BigDecimalToFloatConverter, NumericConverters.BigIntegerToIntegerConverter, NumericConverters.BigIntegerToLongConverter, NumericConverters.DoubleToIntegerConverter, NumericConverters.DoubleToLongConverter, NumericConverters.DoubleToShortConverter, NumericConverters.FloatToIntegerConverter, NumericConverters.FloatToLongConverter, NumericConverters.FloatToShortConverter, NumericConverters.IntegerToShortConverter, NumericConverters.LongToIntegerConverter, NumericConverters.LongToShortConverter, StringToCharacterConverter

public abstract class BidirectionalConverter<S,D>
extends CustomConverter<Object,Object>
implements Converter<Object,Object>

A custom converter that can be extended for mapping from one type to another in both directions

Author:
matt.deboer@gmail.com

Field Summary
 
Fields inherited from class ma.glasnost.orika.CustomConverter
destinationType, mapperFacade, sourceType
 
Constructor Summary
BidirectionalConverter()
           
 
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.
abstract  S convertFrom(D source, Type<S> destinationType)
           
abstract  D convertTo(S source, Type<D> destinationType)
           
 String toString()
           
 
Methods inherited from class ma.glasnost.orika.CustomConverter
getAType, getBType, setMapperFacade
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ma.glasnost.orika.Converter
setMapperFacade
 
Methods inherited from interface ma.glasnost.orika.MappedTypePair
getAType, getBType
 

Constructor Detail

BidirectionalConverter

public BidirectionalConverter()
Method Detail

convertTo

public abstract D convertTo(S source,
                            Type<D> destinationType)

convertFrom

public abstract S convertFrom(D source,
                              Type<S> destinationType)

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.

Specified by:
convert in interface Converter<Object,Object>
Parameters:
source - the source object to be converted
destinationType - the destination type to produce
Returns:
a new instance of destinationType

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:

toString

public String toString()
Overrides:
toString in class CustomConverter<Object,Object>


Copyright © 2013 Glasnost. All Rights Reserved.