Package net.minidev.asm
Class BeansAccess<T>
- java.lang.Object
-
- net.minidev.asm.BeansAccess<T>
-
public abstract class BeansAccess<T> extends Object
Allow access reflect field using runtime generated accessor. BeansAccessor is faster than java.lang.reflect.Method.invoke()- Author:
- uriel Chemouni
-
-
Constructor Summary
Constructors Constructor Description BeansAccess()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <P> BeansAccess<P>
get(Class<P> type)
return the BeansAccess corresponding to a typestatic <P> BeansAccess<P>
get(Class<P> type, FieldFilter filter)
return the BeansAccess corresponding to a typeabstract Object
get(T object, int methodIndex)
get field value by field indexObject
get(T object, String methodName)
get field value by field nameAccessor[]
getAccessors()
int
getIndex(String name)
Returns the index of the field accessor.HashMap<String,Accessor>
getMap()
abstract T
newInstance()
create a new targeted objectabstract void
set(T object, int methodIndex, Object value)
set field value by field indexvoid
set(T object, String methodName, Object value)
set field value by field nameprotected void
setAccessor(Accessor[] accs)
-
-
-
Method Detail
-
setAccessor
protected void setAccessor(Accessor[] accs)
- Parameters:
accs
- Accessor list
-
getAccessors
public Accessor[] getAccessors()
- Returns:
- Accessor list
-
get
public static <P> BeansAccess<P> get(Class<P> type)
return the BeansAccess corresponding to a type- Type Parameters:
P
- working type- Parameters:
type
- to be access- Returns:
- the BeansAccess
-
get
public static <P> BeansAccess<P> get(Class<P> type, FieldFilter filter)
return the BeansAccess corresponding to a type- Type Parameters:
P
- working type- Parameters:
filter
- FieldFiltertype
- to be access- Returns:
- the BeansAccess
-
set
public abstract void set(T object, int methodIndex, Object value)
set field value by field index- Parameters:
object
- object to altermethodIndex
- field id to updatevalue
- new value
-
get
public abstract Object get(T object, int methodIndex)
get field value by field index- Parameters:
object
- object to operatemethodIndex
- field number to operate- Returns:
- value of the field
-
newInstance
public abstract T newInstance()
create a new targeted object- Returns:
- new instance
-
set
public void set(T object, String methodName, Object value)
set field value by field name- Parameters:
object
- target objectmethodName
- methodNamevalue
- new field value
-
get
public Object get(T object, String methodName)
get field value by field name- Parameters:
object
- object to operatemethodName
- getter to call- Returns:
- field value returned by the getter
-
getIndex
public int getIndex(String name)
Returns the index of the field accessor.- Parameters:
name
- field name- Returns:
- id of the field
-
-