Package uk.ac.starlink.table.join

## Class RowLink

- java.lang.Object
- - uk.ac.starlink.table.join.RowLink

- All Implemented Interfaces:
    `java.lang.Comparable<RowLink>`
  Direct Known Subclasses:
    `PairsRowLink`, `RowLink2`

      public class RowLink
      extends java.lang.Object
      implements java.lang.Comparable<RowLink>

  Represents an ordered set of `RowRef`s which are considered in some way linked to each other. Although it doesn't implement the `SortedSet` interface (being immutable this wouldn't gain you much) its spirit is that of a sorted set - its `equals` and `hashCode` methods are implemented such that two `RowLink`s which contain equivalent groups of `RowRef` objects are considered the same. This makes RowLink instances suitable for use as keys in hashes that should not contain duplicate entries for duplicate links. The `getRef` method returns `RowRef`s in their natural order.
  Author:
    Mark Taylor (Starlink)

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RowLink​(java.util.Collection<RowRef> rows)` | Constructs a new RowLink from a Collection of `RowRef` objects.
    `RowLink​(RowRef row)` | Convenience constructor to construct a singleton RowLink.
    `RowLink​(RowRef[] rows)` | Constructs a new RowLink from an array of `RowRef` objects.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `compareTo​(RowLink other)` | Comparison order compares first table (if present in both objects) first, etc.
    `boolean` | `equals​(java.lang.Object o)` | Assesses equality.
    `RowRef` | `getRef​(int i)` | Returns the `i`th row ref in this link.
    `int` | `hashCode()` | Returns a hash code which is consistent with the `equals` method.
    `int` | `size()` | Returns the number of rows linked by this object.
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### RowLink

          public RowLink​(java.util.Collection<RowRef> rows)

      Constructs a new RowLink from a Collection of `RowRef` objects. An unchecked exception will be thrown if `rows` contains some elements which are not instances of `RowRef`.
      Parameters:
        `rows` - collection of `RowRef` objects

    - #### RowLink

          public RowLink​(RowRef[] rows)

      Constructs a new RowLink from an array of `RowRef` objects.
      Parameters:
        `rows` - array of row references

    - #### RowLink

          public RowLink​(RowRef row)

      Convenience constructor to construct a singleton RowLink.
      Parameters:
        `row` - sole row

  - ### Method Detail

    - #### size

          public int size()

      Returns the number of rows linked by this object.
      Returns:
        number of RowRefs

    - #### getRef

          public RowRef getRef​(int i)

      Returns the `i`th row ref in this link.
      Parameters:
        `i` - index
      Returns:
        RowRef at `i`

    - #### equals

          public boolean equals​(java.lang.Object o)

      Assesses equality. Two `RowLink` objects are equal if they contain equivalent sets of `RowRef`s.
      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Returns a hash code which is consistent with the `equals` method. Since `RowLink`s are immutable, this is only calculated once, for efficiency.
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### compareTo

          public int compareTo​(RowLink other)

      Comparison order compares first table (if present in both objects) first, etc.
      Specified by:
        `compareTo` in interface `java.lang.Comparable<RowLink>`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`