|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.sorting.sortingkey.SortingKey
public class SortingKey
The SortingKey
collects different sub-keys and compares different DuDeObject
based on these sub-keys. Each sub-key has to
implement Comparator
based on DuDeObjects
.
Constructor Summary | |
---|---|
SortingKey()
Initializes a SortingKey with no sub-key(s). |
|
SortingKey(Subkey... subkeys)
Initializes a SortingKey instance. |
Method Summary | |
---|---|
SortingKey |
addSubkey(Subkey newSubkey)
Adds a sub-key to the SortingKey . |
int |
compare(DuDeObject record1,
DuDeObject record2)
Compares two DuDeObject s. |
boolean |
equals(Object obj)
|
String |
getKeyString(DuDeObject obj)
Returns the sorting key value of the passed DuDeObject . |
String |
getKeyString(DuDeObject obj,
String splitToken)
Returns the sorting key value of the passed DuDeObject . |
JsonArray |
getKeyValue(DuDeObject obj)
Returns the sorting key value of the passed DuDeObject . |
int |
hashCode()
|
boolean |
isEmpty()
Checks whether any Subkey was added. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SortingKey()
SortingKey
with no sub-key(s). Additional sub-keys can be added using the addSubkey(Subkey)
method. If no
sub-key will be added all DuDeObject
s that are compared based on that sorting key will be equal.
public SortingKey(Subkey... subkeys)
SortingKey
instance. Calling this constructor may cause a compiler warning. The warning can be ignored.
subkeys
- A list of sub-keys that shall be used within the sorting key. (Caution: the order within the parameter list matters!)Method Detail |
---|
public SortingKey addSubkey(Subkey newSubkey)
SortingKey
. (Caution: the order of calling addSubkey() matters!)
newSubkey
- An additional sub-key.
public int compare(DuDeObject record1, DuDeObject record2)
DuDeObject
s.
compare
in interface Comparator<DuDeObject>
record1
- The first DuDeObject
instance.record2
- The second DuDeObject
instance.
0
, if the first DuDeObject
instance is equal to the second one; a value less than 0
,
if the first DuDeObject
instance is lexicographically less than the second one depending on the sorting key; and a value
greater than 0
, if the first DuDeObject
instance is lexicographically greater than the second one depending
on the sorting key.public boolean equals(Object obj)
equals
in interface Comparator<DuDeObject>
equals
in class Object
public String getKeyString(DuDeObject obj)
DuDeObject
.
obj
- The DuDeObject
from which the sorting key shall be returned.
DuDeObject
. If multiple values are generating the
sorting key, they are concatenated without any split token (i.e. the split token is the empty String).getKeyString(DuDeObject, String)
public String getKeyString(DuDeObject obj, String splitToken)
DuDeObject
. The returned String represents the key value that is used for positioning this
object within a sorted collection.
obj
- The DuDeObject
from which the sorting key shall be returned.splitToken
- The token that shall be used for splitting all values.
DuDeObject
. *getKeyValue(DuDeObject)
public JsonArray getKeyValue(DuDeObject obj)
DuDeObject
. The returned JsonArray
is used for positioning this object within a
sorted collection.
obj
- The DuDeObject
from which the sorting key shall be returned.
DuDeObject
. *public int hashCode()
hashCode
in class Object
public boolean isEmpty()
Subkey
was added.
true
, if at least one Subkey
was added; otherwise false
.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |