|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shindig.protocol.conversion.BeanDelegator
public class BeanDelegator
Class to create a delegator (proxy) from an interface to a class. It is used by the GadgetHandler to provide easy separation from interface to actual implementation classes. It uses Java reflection which require the usage of interfaces. The validate function should be used in the test code to validate that all API functions are implemented by the actual data, and it will warn us if actual implementation change and break the API. Delegation support composition, and will create a proxy for fields according To table of classes to proxy.
| Nested Class Summary | |
|---|---|
protected class |
BeanDelegator.DelegateInvocationHandler
|
| Field Summary | |
|---|---|
static String |
NULL
Indicate NULL value for a field (To overcome shortcome of immutable map) |
static com.google.common.collect.ImmutableSet<Class<?>> |
PRIMITIVE_TYPE_CLASSES
List of Classes that are considered primitives and are not proxied |
| Constructor Summary | |
|---|---|
BeanDelegator()
|
|
BeanDelegator(Map<Class<?>,Class<?>> delegatedClasses,
Map<Enum<?>,Enum<?>> enumConvertionMap)
|
|
| Method Summary | ||
|---|---|---|
Enum<?> |
convertEnum(Enum<?> value)
|
|
static Map<Enum<?>,Enum<?>> |
createDefaultEnumMap(Class<? extends Enum<?>> sourceEnum,
Class<? extends Enum<?>> targetEnum)
Utility function to auto generate mapping between two enums that have same values (toString) All values in the sourceEnum must have values in targetEnum, otherwise RuntimeException is thrown |
|
Object |
createDelegator(Object source)
Create a proxy for the real object. |
|
|
createDelegator(Object source,
Class<T> apiInterface)
|
|
|
createDelegator(Object source,
Class<T> apiInterface,
Map<String,Object> extraFields)
|
|
static Object |
nullable(Object o)
Gate a value to use NULL constant instead of null pointer |
|
void |
validate()
Validate all proxied classes to see that all required functions are implemented. |
|
void |
validate(Class<?> dataClass,
Class<?> interfaceClass)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String NULL
public static final com.google.common.collect.ImmutableSet<Class<?>> PRIMITIVE_TYPE_CLASSES
| Constructor Detail |
|---|
public BeanDelegator()
public BeanDelegator(Map<Class<?>,Class<?>> delegatedClasses,
Map<Enum<?>,Enum<?>> enumConvertionMap)
| Method Detail |
|---|
public static Object nullable(Object o)
public Object createDelegator(Object source)
source - item to proxy
public <T> T createDelegator(Object source,
Class<T> apiInterface)
public <T> T createDelegator(Object source,
Class<T> apiInterface,
Map<String,Object> extraFields)
public Enum<?> convertEnum(Enum<?> value)
public void validate()
throws SecurityException,
NoSuchMethodException,
NoSuchFieldException
SecurityException
NoSuchMethodException
NoSuchFieldException
public void validate(Class<?> dataClass,
Class<?> interfaceClass)
throws SecurityException,
NoSuchMethodException,
NoSuchFieldException
SecurityException
NoSuchMethodException
NoSuchFieldException
public static Map<Enum<?>,Enum<?>> createDefaultEnumMap(Class<? extends Enum<?>> sourceEnum,
Class<? extends Enum<?>> targetEnum)
RuntimeException is thrown
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||