jp.develop.common.util.amf
Class Converter

java.lang.Object
  extended by jp.develop.common.util.amf.Converter

public class Converter
extends Object

Object Converter to avoid ClassCastException. You can add conversion rule by adding the implementation of IConverter.

Author:
Waki Takeya
See Also:
AmfDecoderOption

Constructor Summary
Converter()
          Default Constructor.
 
Method Summary
<T> T
convert(Class<T> clazz, Object instance)
          Convert type.
<T> IConverter<? extends T>
getConverter(Class<T> clazz)
          Get custom converter for the class.
static Converter getDefault()
          Get default converter instance.
<T> void
putConverter(Class<T> clazz, IConverter<? extends T> conveter)
          Resister custom converter for the class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Default Constructor.

Method Detail

getDefault

public static Converter getDefault()
Get default converter instance.

Returns:
Default converter instance.

convert

public <T> T convert(Class<T> clazz,
                     Object instance)
Convert type.

Type Parameters:
T - Conversion target type.
Parameters:
clazz - The class of converting to.
instance - Target instance to be converted.
Returns:
Converted instance.

getConverter

public <T> IConverter<? extends T> getConverter(Class<T> clazz)
Get custom converter for the class.

Type Parameters:
T - The type to be converted.
Parameters:
clazz - Target class.
Returns:
The converter for the class.

putConverter

public <T> void putConverter(Class<T> clazz,
                             IConverter<? extends T> conveter)
Resister custom converter for the class.

Type Parameters:
T - The type to be converted.
Parameters:
clazz - The class to be converted.
conveter - The converter for the class.