Class 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 Detail

      • 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 Detail

      • 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