Package uk.ac.starlink.table.join
Class RowLink
java.lang.Object
uk.ac.starlink.table.join.RowLink
- All Implemented Interfaces:
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.
Note: The getRef
method
must return RowRef
s
in their natural (Comparable
) order.
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Comparison order compares first table (if present in both objects) first, etc.static RowLink
createLink
(Collection<RowRef> refs) Returns a RowLink instance for a given collection of RowRefs.boolean
Assesses equality.abstract RowRef
getRef
(int i) Returns thei
th row ref in this ordered sequence of refs.int
hashCode()
Returns a hash code which is consistent with theequals
method.abstract int
size()
Returns the number of rows linked by this object.toString()
-
Constructor Details
-
RowLink
public RowLink()
-
-
Method Details
-
size
public abstract int size()Returns the number of rows linked by this object.- Returns:
- number of RowRefs
-
getRef
Returns thei
th row ref in this ordered sequence of refs. The sequence must be as defined byRowRef.compareTo
.- Parameters:
i
- index- Returns:
- RowRef at
i
-
equals
Assesses equality. TwoRowLink
objects are equal if they contain equivalent sets ofRowRef
s. -
hashCode
public int hashCode()Returns a hash code which is consistent with theequals
method. SinceRowLink
s are immutable, this is only calculated once, for efficiency. -
compareTo
Comparison order compares first table (if present in both objects) first, etc.- Specified by:
compareTo
in interfaceComparable<RowLink>
-
toString
-
createLink
Returns a RowLink instance for a given collection of RowRefs. This may be more efficient than using theRowLinkN
constructor.- Parameters:
refs
- row refs- Returns:
- row link containing given refs
-