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

com.blackbirdai.client.model.SortParam Maven / Gradle / Ivy

package com.blackbirdai.client.model;

import com.blackbirdai.client.InvalidRequestException;
import com.blackbirdai.client.util.Patterns;

public class SortParam extends Param {

    private final String field;
    private final Order order;

    public SortParam(String field, Order order) {
        this.field = field;
        this.order = order;
    }

    @Override
    StringBuilder appendQueryStr(StringBuilder builder) throws InvalidRequestException {
        if (!Patterns.FIELD_P.matcher(field).matches()) {
            throw new InvalidRequestException("Invalid field-name found: " + field);
        }
        builder.append(field);
        builder.append(":");
        builder.append(order.name().toLowerCase());
        return builder;
    }

    public enum Order {
        ASC,
        DESC
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy