Class AbstractLocation

    • Method Detail

      • getDecorator

        public Location getDecorator​(Class decoratorClass)
        Description copied from interface: Location
        Checks the decorator chain for an instance of decoratorClass and return it if found.

        The default behavior is to return null. If the current object is a decorator and is an instance of decoratorClass it should return itself. Otherwise, the decorator should chain this method onto the instance it wraps.

        Specified by:
        getDecorator in interface Location
        Parameters:
        decoratorClass - the Class to check
        Returns:
        a Location if an instance of this class is present in the decorator chain and null otherwise.
      • newInstance

        public Location newInstance​(Location loc)
        Description copied from interface: Location
        Create a new instance of Location with all of the same decorators as this instance but with the data stored in loc.

        The default behavior is to return loc unchanged. If the class is a location decorator then it should instantiate an instance of the same type that decorates loc.

        Specified by:
        newInstance in interface Location
        Parameters:
        loc - the Location to use as template
        Returns:
        a Location instance based on loc with the same decorators as the current instance
      • contains

        public boolean contains​(Location l)
        Description copied from interface: Location
        Checks if this location contains the other.

        Abstractly, a location contains another if every point in the other location is contained within this one.

        Specified by:
        contains in interface Location
        Parameters:
        l - the Location to check
        Returns:
        true if this contains l, otherwise false
      • overlaps

        public boolean overlaps​(Location l)
        Description copied from interface: Location
        Checks if these two locations overlap, using this location's concept of overlapping.

        Abstractly, two locations overlap if they both contain any point.

        Specified by:
        overlaps in interface Location
        Parameters:
        l - the Location to check
        Returns:
        true if they overlap, otherwise false
      • union

        public Location union​(Location loc)
        Description copied from interface: Location
        Return a Location containing all points in either ranges.
        Specified by:
        union in interface Location
        Parameters:
        loc - the Location to union with
        Returns:
        a Location representing the union
      • intersection

        public Location intersection​(Location loc)
        Description copied from interface: Location
        Returns a Location that contains all points common to both ranges.
        Specified by:
        intersection in interface Location
        Parameters:
        loc - the Location to intersect with
        Returns:
        a Location containing all points common to both, or the empty range if there are no such points
      • equals

        public boolean equals​(Object o)
        Description copied from interface: Location
        Checks if this location is equivalent to the other.

        Abstractly, a location is equal to another if for every point in one it is also in the other. This is equivalent to a.contains(b) && b.contains(a). You should call LocationTools.areEqual after casting l to Location.

        Specified by:
        equals in interface Location
        Overrides:
        equals in class Object
        Parameters:
        o - the Object to check
        Returns:
        true if this equals l, otherwise false