Package org.supercsv.util
Class BeanInterfaceProxy
- java.lang.Object
-
- org.supercsv.util.BeanInterfaceProxy
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public final class BeanInterfaceProxy extends java.lang.Object implements java.lang.reflect.InvocationHandler
This is part of the internal implementation of Super CSV.This class creates bean instances based on an interface. This allows you, given an interface for a bean (but no implementation), to generate a bean implementation on-the-fly. This instance can then be used for fetching and storing state. It assumes all get methods starts with "get" and all set methods start with "set" and takes only 1 argument.
- Author:
- Kasper B. Graversen, James Bassett
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> T
createProxy(java.lang.Class<T> proxyInterface)
Creates a proxy object which implements a given bean interface.java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
-
-
-
Method Detail
-
createProxy
public static <T> T createProxy(java.lang.Class<T> proxyInterface)
Creates a proxy object which implements a given bean interface.- Type Parameters:
T
- the proxy implementation type- Parameters:
proxyInterface
- the interface the the proxy will implement- Returns:
- the proxy implementation
- Throws:
java.lang.NullPointerException
- if proxyInterface is null
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
If a getter method is encountered then this method returns the stored value from the bean state (or null if the field has not been set).
If a setter method is encountered then the bean state is updated with the value of the first argument and the value is returned (to allow for method chaining)
- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Throws:
java.lang.IllegalArgumentException
- if the method is not a valid getter/setter
-
-