1 package org.apache.archiva.redback.users; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.util.Arrays; 23 import java.util.HashSet; 24 import java.util.Set; 25 26 27 public interface UserQuery 28 { 29 final static String ORDER_BY_USERNAME = "username"; 30 31 final static String ORDER_BY_FULLNAME = "fullname"; 32 33 final static String ORDER_BY_EMAIL = "email"; 34 35 final static Set<String> ALLOWED_ORDER_FIELDS = 36 new HashSet<String>( Arrays.asList( ORDER_BY_USERNAME, ORDER_BY_FULLNAME, ORDER_BY_EMAIL ) ); 37 38 /** 39 * Returns the case insensitive substring user name criteria. 40 * 41 * @return the username criteria. 42 */ 43 String getUsername(); 44 45 /** 46 * Sets the case insensitive substring user name criteria. 47 * 48 * @param userName the username criteria 49 */ 50 void setUsername( String userName ); 51 52 /** 53 * Returns the case insensitive substring full name criteria. 54 * 55 * @return the username criteria. 56 */ 57 String getFullName(); 58 59 /** 60 * Sets the case insensitive substring full name criteria. 61 * 62 * @param fullName the full name criteria 63 */ 64 void setFullName( String fullName ); 65 66 /** 67 * Returns the case insensitive substring email criteria. 68 * 69 * @return the email criteria. 70 */ 71 String getEmail(); 72 73 /** 74 * Sets the case insensitive substring email criteria. 75 * 76 * @param email the email criteria 77 */ 78 void setEmail( String email ); 79 80 /** 81 * Returns the index (zero based) of the first result to include. Useful for paging. 82 * 83 * @return the first index 84 */ 85 long getFirstResult(); 86 87 /** 88 * Sets the index (zero based) of the first result to include. Useful for paging. 89 * 90 * @param firstResult the first index 91 */ 92 void setFirstResult( int firstResult ); 93 94 /** 95 * Returns the maximum number of users to return. 96 * 97 * @return the maximum number of users to return. 98 */ 99 long getMaxResults(); 100 101 /** 102 * Sets the maximum number of users to return. 103 * 104 * @param maxResults the maximum number of users to return. 105 */ 106 void setMaxResults( int maxResults ); 107 108 /** 109 * Returns the property used to order the results of this query. 110 * This is one of {@link #ORDER_BY_USERNAME}, {@link #ORDER_BY_FULLNAME} or {@link #ORDER_BY_EMAIL}. 111 * 112 * @return the order property. 113 */ 114 String getOrderBy(); 115 116 /** 117 * Sets the property used to order the results of this query. 118 * This is one of {@link #ORDER_BY_USERNAME}, {@link #ORDER_BY_FULLNAME} or {@link #ORDER_BY_EMAIL}. 119 * 120 * @param orderBy the order property. 121 */ 122 void setOrderBy( String orderBy ); 123 124 /** 125 * Returns true if the results should be returned in ascending order. 126 * 127 * @return ascending 128 */ 129 boolean isAscending(); 130 131 /** 132 * Set this to true if the results should be returned in ascending order. 133 * 134 * @param ascending true if the results should be returned in ascending 135 */ 136 void setAscending( boolean ascending ); 137 }