All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.neogroup.warp.data.query.traits.HasOrderByFields Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package org.neogroup.warp.data.query.traits;

import org.neogroup.warp.data.query.fields.SortDirection;
import org.neogroup.warp.data.query.fields.SortField;

import java.util.Collections;
import java.util.List;

public interface HasOrderByFields {

    List getOrderByFields();

    R setOrderByFields (List orderByFields);

    default R orderBy(String... fields) {
        List orderByFields = getOrderByFields();
        for (String field : fields) {
            orderByFields.add(new SortField(field));
        }
        return (R)this;
    }

    default R orderBy(SortField... orderByFields) {
        Collections.addAll(getOrderByFields(), orderByFields);
        return (R)this;
    }

    default R orderBy(String field, SortDirection direction) {
        return orderBy(new SortField(field, direction));
    }

    default R clearOrderByFields() {
        getOrderByFields().clear();
        return (R)this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy