Package repast.simphony.data2
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 Summary
Constructors Constructor Description MethodDataSource(String id, Class<?> clazz, String methodName)
Creates a MethodDataSource that will call the named method on objects of the specified type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Object
get(Object obj)
Gets data given the specified object.Class<?>
getDataType()
Gets the type of data produced by this DataSource.String
getId()
Gets the unique id of this DataSource.net.sf.cglib.reflect.FastMethod
getMethod()
Gets the FastMethod that this MethodDataSource will invoke on a "get".Class<?>
getSourceType()
Gets the type of the object that this DataSource can retreive data from.int
hashCode()
-
-
-
Constructor Detail
-
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 typemethodName
- the name of the method to call
-
-
Method Detail
-
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 interfaceDataSource
- 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 interfaceDataSource
- 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 interfaceNonAggregateDataSource
- 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 interfaceDataSource
- Returns:
- the type of the object that this DataSource can retreive data from.
-
-