Record Class Cord

java.lang.Object
java.lang.Record
com.marcpg.libpg.storing.Cord
Record Components:
x - The X value as a double.
y - The Y value as a double.
z - The Z value as a double.
All Implemented Interfaces:
Serializable

public record Cord(double x, double y, double z) extends Record implements Serializable
Represents a simple coordinate with only X, Y, and Z values.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cord(double x, double y, double z)
    Creates an instance of a Cord record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Cord
    add(@NotNull Cord cord)
    Adds the input cord to this cord.
    static @NotNull Pair<Cord,Cord>
    corners(@NotNull Cord corner1, @NotNull Cord corner2)
    Converts two corners, so one has the lowest x, y and z and one has the highest x, y and z.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    inBounds(double lowX, double highX, double lowY, double highY, double lowZ, double highZ)
    Checks if this Cord lays inside the specified bounds.
    boolean
    inBounds(@NotNull Cord lowCord, @NotNull Cord highCord)
    Checks if this cord lays inside the specified bounds.
    static @NotNull Cord
    ofList(@NotNull List<Integer> list)
    Converts a list of three objects, X, Y, and Z, into a Cord.
    @NotNull Cord
    Swaps the x and z values of this coordinate.
    final String
    Returns a string representation of this record class.
    double
    x()
    Returns the value of the x record component.
    double
    y()
    Returns the value of the y record component.
    double
    z()
    Returns the value of the z record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Cord

      public Cord(double x, double y, double z)
      Creates an instance of a Cord record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
      z - the value for the z record component
  • Method Details

    • add

      @NotNull public @NotNull Cord add(@NotNull @NotNull Cord cord)
      Adds the input cord to this cord. Does not affect this object and creates a new one for the result.
      Parameters:
      cord - The second addend of this addition.
      Returns:
      The sum/total of this addition as a new Cord.
    • rotated

      @NotNull public @NotNull Cord rotated()
      Swaps the x and z values of this coordinate. Does not affect this object and creates a new one for the result.
      Returns:
      The swapped values as a new Cord.
    • inBounds

      public boolean inBounds(@NotNull @NotNull Cord lowCord, @NotNull @NotNull Cord highCord)
      Checks if this cord lays inside the specified bounds.
      Parameters:
      lowCord - The bound's corner containing the lowest X, Y, and Z.
      highCord - The bound's corner containing the highest X, Y, and Z.
      Returns:
      true if this Cord is inside the bounds, false otherwise.
      See Also:
    • inBounds

      public boolean inBounds(double lowX, double highX, double lowY, double highY, double lowZ, double highZ)
      Checks if this Cord lays inside the specified bounds.
      Parameters:
      lowX - The lowest X of the bounds.
      highX - The highest X of the bounds.
      lowY - The lowest Y of the bounds.
      highY - The highest Y of the bounds.
      lowZ - The lowest Z of the bounds.
      highZ - The highest Z of the bounds.
      Returns:
      true if this Cord is inside the bounds, false otherwise.
      See Also:
    • ofList

      @NotNull public static @NotNull Cord ofList(@NotNull @NotNull List<Integer> list)
      Converts a list of three objects, X, Y, and Z, into a Cord.
      Parameters:
      list - The list to convert.
      Returns:
      The converted Cord.
    • corners

      @NotNull public static @NotNull Pair<Cord,Cord> corners(@NotNull @NotNull Cord corner1, @NotNull @NotNull Cord corner2)
      Converts two corners, so one has the lowest x, y and z and one has the highest x, y and z.
      Parameters:
      corner1 - The first corner.
      corner2 - The second corner.
      Returns:
      A pair where the left side has the lower and the right the higher x, y and z.
      Pair<Lowest XYZ, Highest XYZ>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • x

      public double x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • z

      public double z()
      Returns the value of the z record component.
      Returns:
      the value of the z record component