Class BeansAccess<T>

java.lang.Object
net.minidev.asm.BeansAccess<T>
Type Parameters:
T - the type of the bean being accessed

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 Details

    • BeansAccess

      public BeansAccess()
      default constuctor
  • Method Details

    • setAccessor

      protected void setAccessor(Accessor[] accs)
      set Accessor
      Parameters:
      accs - Accessor list
    • getMap

      public HashMap<String,Accessor> getMap()
      get internal map
      Returns:
      a map
    • getAccessors

      public Accessor[] getAccessors()
      get internal accessor
      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 - FieldFilter
      type - 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 alter
      methodIndex - field id to update
      value - new value
    • get

      public abstract Object get(T object, int methodIndex)
      get field value by field index
      Parameters:
      object - object to operate
      methodIndex - 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 object
      methodName - methodName
      value - new field value
    • get

      public Object get(T object, String methodName)
      get field value by field name
      Parameters:
      object - object to operate
      methodName - 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