Package com.iizix

Class Position

java.lang.Object
com.iizix.Position
All Implemented Interfaces:
Serializable, Cloneable

public class Position extends Object implements Cloneable, Serializable
A position with integers.
Author:
Christopher Mindus
See Also:
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    int
    The X position.
    int
    The Y position.
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Constructs a position initialized to 0,0.
    Position(int x, int y)
    Constructs and initializes position.
    Constructs and initializes position.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    static int
    Compares to position by first X, then Y.
    boolean
    Check for equality.
    int
    Hash code.
    Creates the string representation of this position.

    Methods inherited from class java.lang.Object Link icon

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details Link icon

    • x Link icon

      public int x
      The X position.
    • y Link icon

      public int y
      The Y position.
  • Constructor Details Link icon

    • Position Link icon

      public Position()
      Constructs a position initialized to 0,0.
    • Position Link icon

      public Position(int x, int y)
      Constructs and initializes position.
      Parameters:
      x - The X position.
      y - The Y position.
    • Position Link icon

      public Position(Position p)
      Constructs and initializes position.
      Parameters:
      p - The position to clone.
  • Method Details Link icon

    • equals Link icon

      public boolean equals(Object o)
      Check for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - Another object.
      Returns:
      true if it's the same Position object values, false otherwise.
    • hashCode Link icon

      public int hashCode()
      Hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Returns the hash code.
    • toString Link icon

      public String toString()
      Creates the string representation of this position.
      Overrides:
      toString in class Object
      Returns:
      Position String as "className[x=NN,y=NN]".
    • compare Link icon

      public static int compare(Position p1, Position p2)
      Compares to position by first X, then Y.
      Parameters:
      p1 - Position 1 (null allowed).
      p2 - Position 2 (null allowed).
      Returns:
      1 if p1 is "larger" than p2 (or p2 is null), -1 if "smaller" (or p2 is null), 0 if equal (both null).