Search in sources :

Example 1 with IndexType

use of org.mongodb.morphia.utils.IndexType in project morphia by mongodb.

the class IndexBuilder method parseFieldsString.

private List<Field> parseFieldsString(final String str) {
    List<Field> fields = new ArrayList<Field>();
    final String[] parts = str.split(",");
    for (String s : parts) {
        s = s.trim();
        IndexType dir = IndexType.ASC;
        if (s.startsWith("-")) {
            dir = IndexType.DESC;
            s = s.substring(1).trim();
        }
        fields.add(new FieldBuilder().value(s).type(dir));
    }
    return fields;
}
Also used : Field(org.mongodb.morphia.annotations.Field) ArrayList(java.util.ArrayList) IndexType(org.mongodb.morphia.utils.IndexType)

Aggregations

ArrayList (java.util.ArrayList)1 Field (org.mongodb.morphia.annotations.Field)1 IndexType (org.mongodb.morphia.utils.IndexType)1