aQute.lib.converter
Class Converter

java.lang.Object
  extended by aQute.lib.converter.Converter

public class Converter
extends Object

General Java type converter from an object to any type. Supports number conversion

Author:
aqute

Nested Class Summary
static interface Converter.Hook
           
 
Constructor Summary
Converter()
           
 
Method Summary
 Object array(Type type, Object o)
           
static
<T> T
cnv(Class<T> tr, Object source)
           
static Object cnv(Type tr, Object source)
           
static
<T> T
cnv(TypeReference<T> tr, Object source)
           
<T> T
convert(Class<T> type, Object o)
           
 Object convert(Type type, Object o)
           
<T> T
convert(TypeReference<T> type, Object o)
           
 Converter hook(Type type, Converter.Hook hook)
           
static String mangleMethodName(String id)
           
<T> T
proxy(Class<T> interfc, Map<?,?> properties)
          Convert a map to an interface.
 void setFatalIsException(boolean b)
           
 Collection<?> toCollection(Object o)
           
 Map<?,?> toMap(Object o)
           
 
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

convert

public <T> T convert(Class<T> type,
                     Object o)
          throws Exception
Throws:
Exception

convert

public <T> T convert(TypeReference<T> type,
                     Object o)
          throws Exception
Throws:
Exception

convert

public Object convert(Type type,
                      Object o)
               throws Exception
Throws:
Exception

array

public Object array(Type type,
                    Object o)
             throws Exception
Throws:
Exception

toCollection

public Collection<?> toCollection(Object o)

toMap

public Map<?,?> toMap(Object o)
               throws Exception
Throws:
Exception

setFatalIsException

public void setFatalIsException(boolean b)

hook

public Converter hook(Type type,
                      Converter.Hook hook)

proxy

public <T> T proxy(Class<T> interfc,
                   Map<?,?> properties)
Convert a map to an interface.

Parameters:
interfc -
properties -
Returns:

mangleMethodName

public static String mangleMethodName(String id)

cnv

public static <T> T cnv(TypeReference<T> tr,
                        Object source)
             throws Exception
Throws:
Exception

cnv

public static <T> T cnv(Class<T> tr,
                        Object source)
             throws Exception
Throws:
Exception

cnv

public static Object cnv(Type tr,
                         Object source)
                  throws Exception
Throws:
Exception


Copyright © 2014 aQute SARL. All rights reserved.