Record Class Int2

java.lang.Object
java.lang.Record
com.end0katz.blobj.vec.Int2
Record Components:
x - the x component of this vector
y - the y component of this vector
All Implemented Interfaces:
Vec2<Integer,Int2>

public record Int2(Integer x, Integer y) extends Record implements Vec2<Integer,Int2>
Vector containing 2 Integers
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Integer
    The field for the x record component.
    private final Integer
    The field for the y record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a Int2 record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    This is an internal method. override in Vec2 subclasses, but DO NOT CALL YOURSELF.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    double
    Calculate and return the magnitude of this vector.
    int
    Calculate and return the taxicab magnitude of this vector.
    final String
    Returns a string representation of this record class.
    x()
    Returns the value of the x record component.
    y()
    Returns the value of the y record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.end0katz.blobj.vec.Vec2

    asArray, xy, yx
  • Field Details

    • x

      private final Integer x
      The field for the x record component.
    • y

      private final Integer y
      The field for the y record component.
  • Constructor Details

    • Int2

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

    • _createNew

      public Int2 _createNew(Integer x, Integer y)
      Description copied from interface: Vec2
      This is an internal method. override in Vec2 subclasses, but DO NOT CALL YOURSELF.
      Specified by:
      _createNew in interface Vec2<Integer,Int2>
      Parameters:
      x - the x component.
      y - the y component.
      Returns:
      new <thisType>(x, y);
    • magnitude

      public double magnitude()
      Calculate and return the magnitude of this vector.
      Returns:
      the calculated magnitude.
    • taxicab_magnitude

      public int taxicab_magnitude()
      Calculate and return the taxicab magnitude of this vector.
      Returns:
      the calculated magnitude.
      See Also:
    • 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 Objects::equals(Object,Object).
      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 Integer x()
      Returns the value of the x record component.
      Specified by:
      x in interface Vec2<Integer,Int2>
      Returns:
      the value of the x record component
    • y

      public Integer y()
      Returns the value of the y record component.
      Specified by:
      y in interface Vec2<Integer,Int2>
      Returns:
      the value of the y record component