de.uni_paderborn.robots.robot.group10
Class ItemIdMatcher

java.lang.Object
  |
  +--de.uni_paderborn.robots.robot.group10.ItemIdMatcher
All Implemented Interfaces:
MapItemMatcher

public class ItemIdMatcher
extends java.lang.Object
implements MapItemMatcher

Implementation of MapItemMatcher that searches for the shortest path to a map item with a specified id.


Field Summary
protected  int id
          The id to search for.
 
Constructor Summary
ItemIdMatcher(int id)
          Creates a new ItemTypeMatcher that searches for map items with the specified id.
 
Method Summary
 boolean equals(java.lang.Object otherMapItemMatcher)
          Tests if this ItemIdMatcher searches for the same map items as the specified object.
 boolean finished(MapItem mapItem)
          Determines if the search is finished after mapItem is found.
 boolean matches(MapItem mapItem)
          Tests if this map item's id matches the reqested id.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

id

protected int id
The id to search for.
Constructor Detail

ItemIdMatcher

public ItemIdMatcher(int id)
Creates a new ItemTypeMatcher that searches for map items with the specified id.
Parameters:
id - the id to search for
Method Detail

matches

public boolean matches(MapItem mapItem)
Tests if this map item's id matches the reqested id.
Specified by:
matches in interface MapItemMatcher
Parameters:
mapItem - the map item to check
Returns:
true if the id of the specified map item is equal to the id to be searched for

finished

public boolean finished(MapItem mapItem)
Determines if the search is finished after mapItem is found. Because ItemIdMatcher only searches for exactly one map item, the search should immediately stop whenever the first item is found. * @param mapItem map item whose search is completed
Specified by:
finished in interface MapItemMatcher
Parameters:
mapItem - a reference to the mapItem
Returns:
always true

equals

public boolean equals(java.lang.Object otherMapItemMatcher)
Tests if this ItemIdMatcher searches for the same map items as the specified object.
Overrides:
equals in class java.lang.Object
Parameters:
otherMapItemMatcher - an object, preferably an ItemIdMatcher, however it is no harm if something else is passed
Returns:
true if the MapItemMatchers searches for the same object