public final class Samples
extends java.lang.Object
Class Samples
stores a list of samples.
Samples
are immutable.Constructor and Description |
---|
Samples(int[] idIndices)
Constructs a new instance of
Samples corresponding to
the specified list of sample identifier indices. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Returns
true if the specified object is a
Samples object which represents the same ordered
list of samples as this , and returns false
otherwise. |
static Samples |
fromIds(java.lang.String[] ids)
Constructs and returns a
Samples instance
corresponding to the specified list of sample identifiers. |
int |
hashCode()
Returns a hash code value for the object.
|
java.lang.String |
id(int index)
Returns the identifier for the sample with the specified
index in this list of samples.
|
int |
idIndex(int index)
Returns the sample identifier index corresponding to the sample
with the specified index in this list of samples.
|
java.lang.String[] |
ids()
Returns this list of samples as an array of sample identifiers.
|
int |
index(int idIndex)
Returns the index of the sample that corresponds to the
specified sample identifier index, or returns
-1
if there is no corresponding sample in this list of samples. |
int |
index(java.lang.String id)
Returns the index of the sample that corresponds to the
specified sample identifier, or returns
-1
if there is no corresponding sample in this list of samples. |
int |
nSamples()
Returns the number of samples in this list.
|
java.lang.String |
toString()
Returns
java.util.Arrays.toString(this.ids()) . |
public Samples(int[] idIndices)
Samples
corresponding to
the specified list of sample identifier indices.idIndices
- an array of sample identifier indicesjava.lang.IllegalArgumentException
- if the specified array
has two or more elements that are equaljava.lang.IndexOutOfBoundsException
- if any element of the specified
array is negative or greater than or equal to
beagleutil.SampleIds.size()
java.lang.NullPointerException
- if idIndices == null
public static Samples fromIds(java.lang.String[] ids)
Samples
instance
corresponding to the specified list of sample identifiers.ids
- an array of sample identifiers.Samples
instance corresponding to the specified
list of sample identifiersjava.lang.IllegalArgumentException
- if the specified array
has two or more elements that are equal as stringsjava.lang.NullPointerException
- if ids == null
public int hashCode()
Returns a hash code value for the object.
The hash code is defined by the following calculation:
int hash = 1; for (int j, n=this.nSamples(); j<n; ++j) { hash = 31 * hash + this.idIndex(j); }
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
true
if the specified object is a
Samples
object which represents the same ordered
list of samples as this
, and returns false
otherwise.equals
in class java.lang.Object
obj
- the object to be tested for equality with this
true
if the specified object is a
Samples
object which represents the same ordered
list of samples as this
public int idIndex(int index)
index
- a sample indexjava.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.nSamples()
public int index(int idIndex)
-1
if there is no corresponding sample in this list of samples.idIndex
- a sample identifier index-1
if there is no corresponding sample in this list of samplesjava.lang.IndexOutOfBoundsException
- if index < 0
public int index(java.lang.String id)
-1
if there is no corresponding sample in this list of samples.id
- a sample identifier-1
if there is no corresponding sample in this list of samplesjava.lang.NullPointerException
- if id == null
public int nSamples()
public java.lang.String id(int index)
index
- a sample indexjava.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.nSamples()
public java.lang.String[] ids()
this.nSamples()
, and it
satisfies this.ids()[j].equals(this.id(j))
for
0 <= j && j < this.nSamples()
public java.lang.String toString()
java.util.Arrays.toString(this.ids())
.toString
in class java.lang.Object
this