class QueryUtils {

    @Nonnull
    public static List<Order> convertOrderStrings( @Nullable Collection<String> orders, @Nonnull Schema schema )
    {
        if ( orders == null )
        {
            return Collections.emptyList();
        }

        final Map<String, Order> result = new LinkedHashMap<>();
        for ( String o : orders )
        {
            String[] split = o.split( ":" );

            String direction = "asc";

            if ( split.length < 1 )
            {
                continue;
            }
            else if ( split.length == 2 )
            {
                direction = split[1].toLowerCase();
            }

            String propertyName = split[0];
            Property property = schema.getProperty( propertyName );


            if ( result.containsKey( propertyName ) || !schema.haveProperty( propertyName )
                || !validProperty( property ) || !validDirection( direction ) )
            {
                continue;
            }

            result.put( propertyName, Order.from( direction, property ) );
        }

        return new ArrayList<>( result.values() );
    }

}