Example usage for com.mongodb.client.model CollationStrength fromInt

List of usage examples for com.mongodb.client.model CollationStrength fromInt

Introduction

In this page you can find the example usage for com.mongodb.client.model CollationStrength fromInt.

Prototype

public static CollationStrength fromInt(final int intRepresentation) 

Source Link

Document

Gets the order from the given integer representation.

Usage

From source file:org.springframework.data.mongodb.core.Collation.java

License:Apache License

private static Converter<Collation, com.mongodb.client.model.Collation> toMongoCollationConverter() {

    return source -> {

        Builder builder = com.mongodb.client.model.Collation.builder();

        builder.locale(source.locale.asString());

        source.strength.ifPresent(strength -> {

            builder.collationStrength(CollationStrength.fromInt(strength.getLevel()));

            strength.getCaseLevel().ifPresent(builder::caseLevel);
            strength.getCaseFirst()// w ww  .  j  av  a 2  s. c o  m
                    .ifPresent(it -> builder.collationCaseFirst(CollationCaseFirst.fromString(it.state)));
        });

        source.numericOrdering.ifPresent(builder::numericOrdering);
        source.alternate.ifPresent(it -> {

            builder.collationAlternate(CollationAlternate.fromString(it.alternate));
            it.maxVariable.ifPresent(
                    maxVariable -> builder.collationMaxVariable(CollationMaxVariable.fromString(maxVariable)));
        });

        source.backwards.ifPresent(builder::backwards);
        source.normalization.ifPresent(builder::normalization);

        return builder.build();
    };
}