Package org.bremersee.comparator.model
Class ComparatorField
- java.lang.Object
-
- org.bremersee.comparator.model.ComparatorField
-
public class ComparatorField extends Object
This class defines the sort order of a field.--------------------------------------------------------------------------------------------- | Attribute | Description | Default | |--------------|-------------------------------------------------------------------|----------| | add | The add name (or method name) of the object. It can be a path. | null | | | The segments are separated by a dot (.): field0.field1.field2 | | |--------------|-------------------------------------------------------------------|----------| | asc or desc | Defines ascending or descending ordering. | asc | |--------------|-------------------------------------------------------------------|----------| | ignoreCase | Makes a case ignoring comparison (only for strings). | true | |--------------|-------------------------------------------------------------------|----------| | nullIsFirst | Defines the ordering if one of the values is null. | false | ---------------------------------------------------------------------------------------------
These values have a 'well known text' representation. The values are concatenated with comma (,):
fieldNameOrPath,asc,ignoreCase,nullIsFirst
For example:
properties.customSettings.priority,asc,true,false
Defaults can be omitted. This is the same:
properties.customSettings.priority
The building of a chain is done by concatenate the fields with a pipe (|):
field0,asc,ignoreCase,nullIsFirst|field1,asc,ignoreCase,nullIsFirst
- Author:
- Christian Bremer
-
-
Constructor Summary
Constructors Constructor Description ComparatorField()Instantiates a new comparator field.ComparatorField(String field, boolean asc, boolean ignoreCase, boolean nullIsFirst)Instantiates a new comparator field.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)StringgetField()Gets field name or path.inthashCode()booleanisAsc()Is ascending or descending order.booleanisIgnoreCase()Is case insensitive or sensitive order.booleanisNullIsFirst()Is null is first.StringtoString()StringtoWkt()Creates the well known text of this field ordering description.
-
-
-
Constructor Detail
-
ComparatorField
public ComparatorField()
Instantiates a new comparator field.
-
ComparatorField
public ComparatorField(String field, boolean asc, boolean ignoreCase, boolean nullIsFirst)
Instantiates a new comparator field.- Parameters:
field- the field name or path (can benull)asc-truefor an ascending order,falsefor a descending orderignoreCase-truefor a case insensitive order,falsefor a case sensitive ordernullIsFirst- specifies the order ofnullvalues
-
-
Method Detail
-
getField
public String getField()
Gets field name or path.- Returns:
- the field name or path
-
isAsc
public boolean isAsc()
Is ascending or descending order.- Returns:
trueif ascending order,falseif descending order
-
isIgnoreCase
public boolean isIgnoreCase()
Is case insensitive or sensitive order.- Returns:
trueif case insensitive order,falseif case sensitive order
-
isNullIsFirst
public boolean isNullIsFirst()
Is null is first.- Returns:
trueif null is first, otherwisefalse
-
toWkt
public String toWkt()
Creates the well known text of this field ordering description.The syntax of the field ordering description is
fieldNameOrPath,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false
- Returns:
- the well known text
-
-