Class ImmutableCell<V>

  • Type Parameters:
    V - the type of the value
    All Implemented Interfaces:
    java.io.Serializable, Grid.Cell<V>

    public final class ImmutableCell<V>
    extends java.lang.Object
    implements java.io.Serializable
    Immutable implementations of the Grid.Cell data structure.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <R> ImmutableCell<R> copyOf​(Grid.Cell<? extends R> cell)
      Obtains an instance of Cell.
      boolean equalRowColumn​(int row, int column)
      Checks if the row-column of this cell matches the specified row and column.
      boolean equals​(java.lang.Object obj)
      Checks if this cell equals another cell.
      boolean equalValue​(java.lang.Object value)
      Checks if the value of this cell matches the specified value.
      int getColumn()
      Gets the column index.
      int getRow()
      Gets the row index.
      V getValue()
      Gets the value of the cell.
      int hashCode()
      Gets a suitable hash code.
      static <R> ImmutableCell<R> of​(int row, int column, R value)
      Obtains an instance of Cell.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • of

        public static <R> ImmutableCell<R> of​(int row,
                                              int column,
                                              R value)
        Obtains an instance of Cell.
        Type Parameters:
        R - the type of the value
        Parameters:
        row - the row, zero or greater
        column - the column, zero or greater
        value - the value to put into the grid, not null
        Returns:
        the immutable cell, not null
        Throws:
        java.lang.IndexOutOfBoundsException - if either index is less than zero
      • copyOf

        public static <R> ImmutableCell<R> copyOf​(Grid.Cell<? extends R> cell)
        Obtains an instance of Cell.
        Type Parameters:
        R - the type of the value
        Parameters:
        cell - the cell to copy, not null
        Returns:
        the immutable cell, not null
      • getRow

        public int getRow()
        Description copied from interface: Grid.Cell
        Gets the row index.
        Specified by:
        getRow in interface Grid.Cell<V>
        Returns:
        the row, zero or greater
      • getColumn

        public int getColumn()
        Description copied from interface: Grid.Cell
        Gets the column index.
        Specified by:
        getColumn in interface Grid.Cell<V>
        Returns:
        the column, zero or greater
      • getValue

        public V getValue()
        Description copied from interface: Grid.Cell
        Gets the value of the cell.
        Specified by:
        getValue in interface Grid.Cell<V>
        Returns:
        the cell value, not null
      • equalRowColumn

        public boolean equalRowColumn​(int row,
                                      int column)
        Description copied from interface: Grid.Cell
        Checks if the row-column of this cell matches the specified row and column.
        Specified by:
        equalRowColumn in interface Grid.Cell<V>
        Parameters:
        row - the row to check
        column - the column to check
        Returns:
        true if equal
      • equalValue

        public boolean equalValue​(java.lang.Object value)
        Description copied from interface: Grid.Cell
        Checks if the value of this cell matches the specified value.
        Specified by:
        equalValue in interface Grid.Cell<V>
        Parameters:
        value - the row to check, null returns false
        Returns:
        true if equal
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: Grid.Cell
        Checks if this cell equals another cell.

        Two cells are equal if they have equal row, column and value.

        Specified by:
        equals in interface Grid.Cell<V>
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare to, null returns false
        Returns:
        true if equal
      • hashCode

        public int hashCode()
        Description copied from interface: Grid.Cell
        Gets a suitable hash code.

        The hash code is row ^ Integer.rotateLeft(column, 16) ^ value.hashCode().

        Specified by:
        hashCode in interface Grid.Cell<V>
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object