com.amazon.carbonado.util
Class Converter

java.lang.Object
  extended by com.amazon.carbonado.util.Converter

public abstract class Converter
extends Object

General purpose type converter. Custom conversions are possible by supplying an abstract subclass which has public conversion methods whose names begin with "convert". Each conversion method takes a single argument and returns a value.

Since:
1.2
Author:
Brian S O'Neill

Constructor Summary
Converter()
           
 
Method Summary
static
<C extends Converter>
C
build(Class<C> converterType)
           
static
<C extends Converter>
Class<? extends C>
buildClass(Class<C> converterType)
           
protected  IllegalArgumentException conversionNotSupported(Object fromValue, Class fromType, Class toType)
           
abstract
<T> T
convert(boolean from, Class<T> toType)
           
abstract
<T> T
convert(byte from, Class<T> toType)
           
abstract
<T> T
convert(char from, Class<T> toType)
           
abstract
<T> T
convert(double from, Class<T> toType)
           
abstract
<T> T
convert(float from, Class<T> toType)
           
abstract
<T> T
convert(int from, Class<T> toType)
           
abstract
<T> T
convert(long from, Class<T> toType)
           
abstract
<T> T
convert(Object from, Class<T> toType)
           
abstract
<T> T
convert(short from, Class<T> toType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Method Detail

build

public static <C extends Converter> C build(Class<C> converterType)
Parameters:
converterType - type of converter to generate
Throws:
IllegalArgumentException - if converter doesn't a no-arg constructor

buildClass

public static <C extends Converter> Class<? extends C> buildClass(Class<C> converterType)
Parameters:
converterType - type of converter to generate

convert

public abstract <T> T convert(Object from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(byte from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(short from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(int from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(long from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(float from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(double from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(boolean from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

convert

public abstract <T> T convert(char from,
                              Class<T> toType)
Throws:
IllegalArgumentException - if conversion is not supported

conversionNotSupported

protected IllegalArgumentException conversionNotSupported(Object fromValue,
                                                          Class fromType,
                                                          Class toType)


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.