Class MethodDataSource

java.lang.Object
repast.simphony.data2.MethodDataSource
All Implemented Interfaces:
DataSource, NonAggregateDataSource

public class MethodDataSource extends Object implements NonAggregateDataSource
DataSource that retrieves data from a method call on an object.
Author:
Nick Collier
  • Constructor Details

    • MethodDataSource

      public MethodDataSource(String id, Class<?> clazz, String methodName)
      Creates a MethodDataSource that will call the named method on objects of the specified type. The method must not return void and must take 0 arguments.
      Parameters:
      id - a unique identifier for this DataSource.
      clazz - the object type
      methodName - the name of the method to call
  • Method Details

    • getMethod

      public net.sf.cglib.reflect.FastMethod getMethod()
      Gets the FastMethod that this MethodDataSource will invoke on a "get".
      Returns:
      the FastMethod that this MethodDataSource will invoke on a "get".
    • getDataType

      public Class<?> getDataType()
      Description copied from interface: DataSource
      Gets the type of data produced by this DataSource.
      Specified by:
      getDataType in interface DataSource
      Returns:
      the type of data produced by this DataSource.
    • getId

      public String getId()
      Description copied from interface: DataSource
      Gets the unique id of this DataSource. The id should be unique across the DataSet that this source is added to.
      Specified by:
      getId in interface DataSource
      Returns:
      the unique id of this DataSource.
    • get

      public Object get(Object obj)
      Description copied from interface: NonAggregateDataSource
      Gets data given the specified object.
      Specified by:
      get in interface NonAggregateDataSource
      Parameters:
      obj - an object to get the data from
      Returns:
      the retrieved data.
    • getSourceType

      public Class<?> getSourceType()
      Description copied from interface: DataSource
      Gets the type of the object that this DataSource can retreive data from.
      Specified by:
      getSourceType in interface DataSource
      Returns:
      the type of the object that this DataSource can retreive data from.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object