# CollationService

CollationService provides a comparator that can be used for sorting or matching string values.

In many situations, collation can be specified using the @Collation annotation rather than through a custom CollationService implementation. The annotation supports Sapphire EL.

    @Unique
    @Collation( ignoreCaseDifferences = "true" )

    ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" );

    Value<String> getName();
    void setName( String value );

When more control is necessary, a custom implementation of CollationService can be provided.

    @Unique
    @Service( impl = ExampleCollationService.class )

    ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" );

    Value<String> getName();
    void setName( String value );

    public class ExampleCollationService extends CollationService
    {
        @Override
        protected Comparator<String> compute()
        {
            return new Comparator()
            {
                public int compare( final String a, final String b )
                {
                    ...
                }
            };
        }
    }

Copyright (c) 2015 Oracle
Content made available under the terms of Eclipse Public License.