Class QueryParameters<M>

  • Type Parameters:
    M - Provide entity specific type checking, for example, when we create QueryParameters instance for Users, M is equal to UserModel, hence we are not able, for example, to order result by a SearchableModelField defined for clients in ClientModel.

    public class QueryParameters<M>
    extends Object
    Wraps together parameters for querying storage e.g. number of results to return, requested order or filtering criteria
    • Constructor Detail

      • QueryParameters

        public QueryParameters()
    • Method Detail

      • withCriteria

        public static <M> QueryParameters<M> withCriteria​(DefaultModelCriteria<M> mcb)
        Creates a new QueryParameters instance initialized with ModelCriteriaBuilder
        Type Parameters:
        M - model type
        mcb - filtering criteria
        a new QueryParameters instance
      • pagination

        public QueryParameters<M> pagination​(Integer offset,
                                             Integer limit,
                                             SearchableModelField<M> orderByAscField)
        Sets pagination (offset, limit and orderBy) parameters to QueryParameters
        offset -
        limit -
        orderByAscField -
        this object
      • orderBy

        public QueryParameters<M> orderBy​(SearchableModelField<M> searchableModelField,
                                          QueryParameters.Order order)
        Sets orderBy parameter; can be called repeatedly; fields are stored in a list where the first field has highest priority when determining order; e.g. the second field is compared only when values for the first field are equal
        searchableModelField -
        this object
      • offset

        public QueryParameters<M> offset​(Integer offset)
        Sets offset parameter
        offset -
      • getOffset

        public Integer getOffset()
      • getLimit

        public Integer getLimit()