Class DelegatedIterable<AGENT_TYPE>

java.lang.Object
repast.simphony.util.collections.DelegatedIterable<AGENT_TYPE>
All Implemented Interfaces:
Iterable<AGENT_TYPE>

public class DelegatedIterable<AGENT_TYPE> extends Object implements Iterable<AGENT_TYPE>
An iterable that retrieves the iterator when needed based on a method call. You specify the method to call and the object to call it on and it returns the result of the method call from iterator()
Version:
$Revision: 1.1 $ $Date: 2005/12/21 22:25:35 $
Author:
Jerry Vos
  • Constructor Summary

    Constructors
    Constructor
    Description
    DelegatedIterable(Object toCallOn, Method methodToCall)
    Constructs this with the object to call the method on as toCallOn and the method to call as methodToCall [toCallOn.methodToCall()].
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the object is a DelegatedIterable and its method and object to call on are equal
    int
    Returns a hash code based on the object the method is to be called on and the method to call.
    Fetches the result of calling the specified method on the specified object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • DelegatedIterable

      public DelegatedIterable(Object toCallOn, Method methodToCall)
      Constructs this with the object to call the method on as toCallOn and the method to call as methodToCall [toCallOn.methodToCall()].
      Parameters:
      toCallOn - the object to call the specified method on
      methodToCall - the method to call on the object (must return Iterable and take no arguments)
  • Method Details

    • iterator

      public Iterator<AGENT_TYPE> iterator()
      Fetches the result of calling the specified method on the specified object.
      Specified by:
      iterator in interface Iterable<AGENT_TYPE>
      Returns:
      the return value of toCallOn.methodToCall()
    • hashCode

      public int hashCode()
      Returns a hash code based on the object the method is to be called on and the method to call.
      Overrides:
      hashCode in class Object
      Returns:
      toCallOn.hashCode() ^ methodToCall.hashCode()
    • equals

      public boolean equals(Object obj)
      Checks if the object is a DelegatedIterable and its method and object to call on are equal
      Overrides:
      equals in class Object
      Returns:
      if the objects share an equal method and method invocation target