Package uk.ac.starlink.table.join
Class RowLink
- java.lang.Object
-
- uk.ac.starlink.table.join.RowLink
-
- All Implemented Interfaces:
java.lang.Comparable<RowLink>
public abstract class RowLink extends java.lang.Object implements java.lang.Comparable<RowLink>
Represents an ordered set ofRowRef
s which are considered in some way linked to each other. Although it doesn't implement theSortedSet
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 RowLinks 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 RowRefs in their natural (
Comparable
) order.- Author:
- Mark Taylor (Starlink)
-
-
Constructor Summary
Constructors Constructor Description RowLink()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(RowLink other)
Comparison order compares first table (if present in both objects) first, etc.static RowLink
createLink(java.util.Collection<RowRef> refs)
Returns a RowLink instance for a given collection of RowRefs.boolean
equals(java.lang.Object o)
Assesses equality.abstract RowRef
getRef(int i)
Returns the ith row ref in this ordered sequence of refs.int
hashCode()
Returns a hash code which is consistent with the equals method.abstract int
size()
Returns the number of rows linked by this object.java.lang.String
toString()
-
-
-
Method Detail
-
size
public abstract int size()
Returns the number of rows linked by this object.- Returns:
- number of RowRefs
-
getRef
public abstract RowRef getRef(int i)
Returns the ith row ref in this ordered sequence of refs. The sequence must be as defined byRowRef.compareTo
.- 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 RowRefs.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Returns a hash code which is consistent with the equals method. Since RowLinks are immutable, this is only calculated once, for efficiency.- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(RowLink other)
Comparison order compares first table (if present in both objects) first, etc.- Specified by:
compareTo
in interfacejava.lang.Comparable<RowLink>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-