|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.quick.StringObjectPair
StringObjectPair constructs an immutable pair object from
a non-null String and
a non-null Object.
The methods equals and hashCode are designed
so that two StringObjectPair objects whose contents are
equal will be considered equal and will return the same hash code.
| Field Summary | |
private Object |
object
The Object item of the pair. |
private String |
string
The String item of the pair. |
| Constructor Summary | |
StringObjectPair(Object[] data)
Constructor that constructs a pair using a non- null array of Object
such that the array has 2 items,
item 0 is a non-null String and
item 1 is a non-null Object. |
|
StringObjectPair(String string,
Object object)
Constructor that constructs a pair using a non- null String and
a non-null Object. |
|
| Method Summary | |
boolean |
equals(Object entity)
If the given entity is an instance of StringObjectPair and
if the corresponding items in this pair and the given entity are equal,
then returns true; otherwise returns false. |
Object |
getObject()
Returns the object in the pair. |
static Object[] |
getObjects(StringObjectPair[] pairs)
Returns the array of objects from this array of pairs. |
String |
getString()
Returns the string in the pair. |
static String[] |
getStrings(StringObjectPair[] pairs)
Returns the array of strings from this array of pairs. |
int |
hashCode()
Returns a hash code value for this pair that is computed as the exclusive OR of the hash code values for the two items in the pair. |
static StringObjectPair |
makeStringObjectPair(Object[] data)
Factory method that returns a StringObjectPair if the data
array is non-null, has exactly two non-null items,
and the first item is a String;
otherwise returns null. |
static StringObjectPair |
makeStringObjectPair(Object a,
Object b)
Factory method that returns a StringObjectPair if the two
objects are non-null and the first is a String;
otherwise returns null. |
Object[] |
toArray()
Returns the contents of the pair as an array of Object
of length 2. |
static StringObjectPair[] |
toArray(Object[][] array)
Returns the contents of the given Object[][] array as
a StringObjectPair[] array. |
static Object[][] |
toArray(StringObjectPair[] pairs)
Returns the contents of the given StringObjectPair[] array
as an Object[][] array. |
String |
toString()
Returns the String constructed as:
(getString(), getObject().toString()). |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
private String string
private Object object
| Constructor Detail |
public StringObjectPair(String string,
Object object)
Constructor that constructs a pair using
a non-null String and
a non-null Object.
string - the string for the pairobject - the object for the pair
NullPointerException - if either data item is
nullpublic StringObjectPair(Object[] data)
Constructor that constructs a pair using
a non-null array of Object
such that the array has 2 items,
item 0 is a non-null String and
item 1 is a non-null Object.
data - the data array
NullPointerException - if data is null
or if an array item in data is null
IllegalArgumentException - if data does not have length 2
or if data[0] is not of type String| Method Detail |
public String getString()
public Object getObject()
public boolean equals(Object entity)
If the given entity is an instance of StringObjectPair and
if the corresponding items in this pair and the given entity are equal,
then returns true; otherwise returns false.
entity - the entity to compare to this pair
public int hashCode()
Returns a hash code value for this pair that is computed as the exclusive OR of the hash code values for the two items in the pair.
public String toString()
Returns the String constructed as:
(getString(), getObject().toString()).
public Object[] toArray()
Returns the contents of the pair as an array of Object
of length 2.
public static StringObjectPair makeStringObjectPair(Object a,
Object b)
Factory method that returns a StringObjectPair if the two
objects are non-null and the first is a String;
otherwise returns null.
Does not throw any exceptions.
a - the string for the pairb - the object for the pairpublic static StringObjectPair makeStringObjectPair(Object[] data)
Factory method that returns a StringObjectPair if the data
array is non-null, has exactly two non-null items,
and the first item is a String;
otherwise returns null.
Does not throw any exceptions.
data - the data with which to form the pair if possibleStringObjectPair(Object[])public static Object[][] toArray(StringObjectPair[] pairs)
Returns the contents of the given StringObjectPair[] array
as an Object[][] array.
pairs - the 1-dimensional pair array
public static StringObjectPair[] toArray(Object[][] array)
Returns the contents of the given Object[][] array as
a StringObjectPair[] array.
Uses makeStringObjectPair(Object[]) to make the individual
items in the returned StringObjectPair[] array. In this way,
items in the original array that cannot make a suitable pair will map to
null.
array - the 2-dimensional object array
public static String[] getStrings(StringObjectPair[] pairs)
pairs - the 1-dimensional pair array
public static Object[] getObjects(StringObjectPair[] pairs)
pairs - the 1-dimensional pair array
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||