
htsjdk.samtools.util.ComparableTuple Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of htsjdk Show documentation
Show all versions of htsjdk Show documentation
A Java API for high-throughput sequencing data (HTS) formats
package htsjdk.samtools.util;
/**
* A simple extension of the Tuple class that, for comparable Types, allows comparing Tuples of non-null elements.
*
* The comparison will compare the first arguments and if equal (compareTo returns 0) compare the second arguments.
*
* @author farjoun
*/
public class ComparableTuple, B extends Comparable> extends Tuple implements Comparable> {
public ComparableTuple(final A a, final B b) {
super(a, b);
if (a == null || b == null) {
throw new IllegalArgumentException("ComparableTuple's behavior is undefined when containing a null.");
}
}
@Override
public int compareTo(final ComparableTuple o) {
int retval = a.compareTo(o.a);
if (retval == 0) {
retval = b.compareTo(o.b);
}
return retval;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy