private static Converter<Collation, Document> toMongoDocumentConverter() { return source -> { Document document = new Document(); document.append("locale", source.locale.asString()); source.strength.ifPresent(strength -> { document.append("strength", strength.getLevel()); strength.getCaseLevel().ifPresent(it -> document.append("caseLevel", it)); strength.getCaseFirst().ifPresent(it -> document.append("caseFirst", it.state)); }); source.numericOrdering.ifPresent(val -> document.append("numericOrdering", val)); source.alternate.ifPresent(it -> { document.append("alternate", it.alternate); it.maxVariable.ifPresent(maxVariable -> document.append("maxVariable", maxVariable)); }); source.backwards.ifPresent(it -> document.append("backwards", it)); source.normalization.ifPresent(it -> document.append("normalization", it)); source.version.ifPresent(it -> document.append("version", it)); return document; }; }
/** * Set the flag that determines sort order of case differences during tertiary level comparisons. * * @param caseFirst must not be {@literal null}. * @return */ public Collation caseFirst(CaseFirst sort) { ComparisonLevel strengthValue = strength.orElseGet(ComparisonLevel::tertiary); return strength(new ICUComparisonLevel(strengthValue.getLevel(), Optional.of(sort), strengthValue.getCaseLevel())); }
/** * Set whether to include {@code caseLevel} comparison. <br /> * * @param caseLevel * @return new {@link Collation}. */ public Collation caseLevel(boolean caseLevel) { ComparisonLevel strengthValue = strength.orElseGet(ComparisonLevel::primary); return strength( new ICUComparisonLevel(strengthValue.getLevel(), strengthValue.getCaseFirst(), Optional.of(caseLevel))); }
builder.collationStrength(CollationStrength.fromInt(strength.getLevel()));
private static Converter<Collation, Document> toMongoDocumentConverter() { return source -> { Document document = new Document(); document.append("locale", source.locale.asString()); source.strength.ifPresent(strength -> { document.append("strength", strength.getLevel()); strength.getCaseLevel().ifPresent(it -> document.append("caseLevel", it)); strength.getCaseFirst().ifPresent(it -> document.append("caseFirst", it.state)); }); source.numericOrdering.ifPresent(val -> document.append("numericOrdering", val)); source.alternate.ifPresent(it -> { document.append("alternate", it.alternate); it.maxVariable.ifPresent(maxVariable -> document.append("maxVariable", maxVariable)); }); source.backwards.ifPresent(it -> document.append("backwards", it)); source.normalization.ifPresent(it -> document.append("normalization", it)); source.version.ifPresent(it -> document.append("version", it)); return document; }; }
/** * Set the flag that determines sort order of case differences during tertiary level comparisons. * * @param caseFirst must not be {@literal null}. * @return */ public Collation caseFirst(CaseFirst sort) { ComparisonLevel strengthValue = strength.orElseGet(ComparisonLevel::tertiary); return strength(new ICUComparisonLevel(strengthValue.getLevel(), Optional.of(sort), strengthValue.getCaseLevel())); }
/** * Set whether to include {@code caseLevel} comparison. <br /> * * @param caseLevel * @return new {@link Collation}. */ public Collation caseLevel(boolean caseLevel) { ComparisonLevel strengthValue = strength.orElseGet(ComparisonLevel::primary); return strength( new ICUComparisonLevel(strengthValue.getLevel(), strengthValue.getCaseFirst(), Optional.of(caseLevel))); }
builder.collationStrength(CollationStrength.fromInt(strength.getLevel()));