org.joda.collect.grid
Class ImmutableCell<V>

java.lang.Object
  extended by org.joda.collect.grid.ImmutableCell<V>
Type Parameters:
V - the type of the value
All Implemented Interfaces:
Serializable, Grid.Cell<V>

public final class ImmutableCell<V>
extends Object
implements Serializable

Immutable implementations of the Grid.Cell data structure.

See Also:
Serialized Form

Method Summary
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(Object obj)
          Checks if this cell equals another cell.
 boolean equalValue(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.
 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:
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(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(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 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 Object
Returns:
the hash code

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014–2017 Joda.org. All rights reserved.