1package org.apache.archiva.metadata;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import java.util.Arrays;
23import java.util.Collections;
24import java.util.List;
2526/**27 *28 * This class is used to provide additional query parameters to search queries.29 * These parameters are hints for the metadata repository implementation, some parameters may be ignored.30 *31 * The defaults are:32 * <li>33 * <ul>Sort order: ascending</ul>34 * <ul>Offset: 0</ul>35 * <ul>Limit: Long.MAX_VALUE</ul>36 * <ul>Sort fields: empty, which means it depends on the query</ul>37 * </li>38 *39 * @author Martin Stockhammer <martin_s@apache.org>40 */41publicclassQueryParameter {
4243finalboolean ascending;
44final List<String> sortFields;
45finallong offset;
46finallong limit;
4748publicQueryParameter(boolean isAscending, long offset, long limit, String... sortFields) {
49this.ascending = isAscending;
50this.offset = offset;
51this.limit = limit;
52this.sortFields = Arrays.asList(sortFields);
53 }
5455publicQueryParameter(long offset, long limit) {
56this.offset=offset;
57this.limit = limit;
58this.ascending = true;
59this.sortFields = Collections.emptyList();
60 }
6162publicQueryParameter(boolean isAscending, long offset, long limit) {
63this.ascending = isAscending;
64this.offset = offset;
65this.limit = limit;
66this.sortFields = Collections.emptyList();
67 }
6869publicQueryParameter(long limit) {
70this.offset=0;
71this.ascending=true;
72this.limit=limit;
73this.sortFields = Collections.emptyList();
74 }
7576publicQueryParameter() {
77this.ascending = true;
78this.sortFields = Collections.emptyList();
79this.offset = 0;
80this.limit = Long.MAX_VALUE;
81 }
8283publicboolean isAscending() {
84return ascending;
85 }
8687public List<String> getSortFields() {
88return sortFields;
89 }
9091publiclong getOffset() {
92return offset;
93 }
9495publiclong getLimit() {
96return limit;
97 }
98 }