Class Collation
java.lang.Object
org.springframework.data.mongodb.core.query.Collation
Central abstraction for MongoDB collation support.
Allows fluent creation of a collation
NOTE: Please keep in mind that queries will only make use of an index with collation settings if the query itself specifies the same collation.
Allows fluent creation of a collation
Document
that can be used for creating collections & indexes as well as
querying data.
NOTE: Please keep in mind that queries will only make use of an index with collation settings if the query itself specifies the same collation.
- Since:
- 2.0
- Author:
- Christoph Strobl, Mark Paluch, Jens Schauder
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
ICU locale abstraction for usage with MongoDBCollation
.static interface
Abstraction for the ICU Comparison Levels.static class
Primary-strengthCollation.ICUComparisonLevel
.static class
Secondary-strengthCollation.ICUComparisonLevel
.static class
Tertiary-strengthCollation.ICUComparisonLevel
. -
Method Summary
Modifier and TypeMethodDescriptionSet the Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.alternate
(Collation.Alternate alternate) Set the Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.Sort string with diacritics sort from back of the string.backwards
(boolean backwards) Set the flag that determines whether strings with diacritics sort from back of the string.Set the flag that determines sort order of case differences during tertiary level comparisons.caseFirst
(Collation.CaseFirst sort) Set the flag that determines sort order of case differences during tertiary level comparisons.caseLevel
(boolean caseLevel) Set whether to includecaseLevel
comparison.boolean
Do not sort string with diacritics sort from back of the string.static Collation
from
(org.bson.Document source) Create newCollation
from values inDocument
.int
hashCode()
<R> R
maxVariable
(String maxVariable) Set the field that determines up to which characters are considered ignorable when alternate isshifted
.normalization
(boolean normalization) Set the flag that determines whether to check if text require normalization and to perform normalization.Disable text normalization.Enable text normalization.numericOrdering
(boolean flag) Set the flag that determines whether to compare numeric strings as numbers or as strings.Treat numeric strings as string for comparison.Treat numeric strings as numbers for comparison.static Collation
Create newCollation
with locale set to the given ICU language.static Collation
static Collation
of
(Collation.CollationLocale locale) Create newCollation
with locale set to the givenCollation.CollationLocale
.static Collation
Parse the givencollation
string into aCollation
.static Collation
simple()
Create aCollation
using simple binary comparison.strength
(int strength) Set the level of comparison to perform.strength
(Collation.ComparisonLevel comparisonLevel) Set the level of comparison to perform.org.bson.Document
Get theDocument
representation of theCollation
.com.mongodb.client.model.Collation
Get theCollation
representation of theCollation
.toString()
-
Method Details
-
simple
Create aCollation
using simple binary comparison.- Returns:
- a
Collation
for simple binary comparison.
-
of
- Parameters:
locale
- must not be null.- Returns:
- new instance of
Collation
.
-
of
Create newCollation
with locale set to the given ICU language.- Parameters:
language
- must not be null.- Returns:
- new instance of
Collation
.
-
of
Create newCollation
with locale set to the givenCollation.CollationLocale
.- Parameters:
locale
- must not be null.- Returns:
- new instance of
Collation
.
-
parse
Parse the givencollation
string into aCollation
.- Parameters:
collation
- the collation to parse. Can be a simple string likeen_US
or aparsable
document like{ 'locale' : '?0' }
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- if collation is null.- Since:
- 2.2
-
from
Create newCollation
from values inDocument
.- Parameters:
source
- must not be null.- Returns:
- new instance of
Collation
. - See Also:
-
strength
Set the level of comparison to perform.- Parameters:
strength
- comparison level.- Returns:
- new
Collation
.
-
strength
Set the level of comparison to perform.- Parameters:
comparisonLevel
- must not be null.- Returns:
- new
Collation
-
caseLevel
Set whether to includecaseLevel
comparison.- Parameters:
caseLevel
- use true to enablecaseLevel
comparison.- Returns:
- new
Collation
.
-
caseFirst
Set the flag that determines sort order of case differences during tertiary level comparisons.- Parameters:
caseFirst
- must not be null.- Returns:
- new instance of
Collation
.
-
caseFirst
Set the flag that determines sort order of case differences during tertiary level comparisons.- Parameters:
sort
- must not be null.- Returns:
- new instance of
Collation
.
-
numericOrderingEnabled
Treat numeric strings as numbers for comparison.- Returns:
- new
Collation
.
-
numericOrderingDisabled
Treat numeric strings as string for comparison.- Returns:
- new
Collation
.
-
numericOrdering
Set the flag that determines whether to compare numeric strings as numbers or as strings.- Returns:
- new
Collation
.
-
alternate
Set the Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.- Parameters:
alternate
- must not be null.- Returns:
- new
Collation
.
-
alternate
Set the Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.- Parameters:
alternate
- must not be null.- Returns:
- new
Collation
.
-
backwardDiacriticSort
Sort string with diacritics sort from back of the string.- Returns:
- new
Collation
.
-
forwardDiacriticSort
Do not sort string with diacritics sort from back of the string.- Returns:
- new
Collation
.
-
backwards
Set the flag that determines whether strings with diacritics sort from back of the string.- Parameters:
backwards
- must not be null.- Returns:
- new
Collation
.
-
normalizationEnabled
Enable text normalization.- Returns:
- new
Collation
.
-
normalizationDisabled
Disable text normalization.- Returns:
- new
Collation
.
-
normalization
Set the flag that determines whether to check if text require normalization and to perform normalization.- Parameters:
normalization
- must not be null.- Returns:
- new
Collation
.
-
maxVariable
Set the field that determines up to which characters are considered ignorable when alternate isshifted
.- Parameters:
maxVariable
- must not be null.- Returns:
- new
Collation
.
-
toDocument
public org.bson.Document toDocument()Get theDocument
representation of theCollation
.- Returns:
- the native MongoDB
Document
representation of theCollation
.
-
toMongoCollation
public com.mongodb.client.model.Collation toMongoCollation()Get theCollation
representation of theCollation
.- Returns:
- he native MongoDB representation of the
Collation
.
-
map
public <R> R map(org.springframework.core.convert.converter.Converter<? super Collation, ? extends R> mapper) - Type Parameters:
R
-- Parameters:
mapper
- must not be null.- Returns:
- the converted result.
-
toString
-
equals
-
hashCode
public int hashCode()
-