001package org.apache.archiva.redback.users;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Arrays;
023import java.util.HashSet;
024import java.util.Set;
025
026
027public interface UserQuery
028{
029    final static String ORDER_BY_USERNAME = "username";
030
031    final static String ORDER_BY_FULLNAME = "fullname";
032
033    final static String ORDER_BY_EMAIL = "email";
034
035    final static Set<String> ALLOWED_ORDER_FIELDS =
036        new HashSet<String>( Arrays.asList( ORDER_BY_USERNAME, ORDER_BY_FULLNAME, ORDER_BY_EMAIL ) );
037
038    /**
039     * Returns the case insensitive substring user name criteria.
040     *
041     * @return the username criteria.
042     */
043    String getUsername();
044
045    /**
046     * Sets the case insensitive substring user name criteria.
047     *
048     * @param userName the username criteria
049     */
050    void setUsername( String userName );
051
052    /**
053     * Returns the case insensitive substring full name criteria.
054     *
055     * @return the username criteria.
056     */
057    String getFullName();
058
059    /**
060     * Sets the case insensitive substring full name criteria.
061     *
062     * @param fullName the full name criteria
063     */
064    void setFullName( String fullName );
065
066    /**
067     * Returns the case insensitive substring email criteria.
068     *
069     * @return the email criteria.
070     */
071    String getEmail();
072
073    /**
074     * Sets the case insensitive substring email criteria.
075     *
076     * @param email the email criteria
077     */
078    void setEmail( String email );
079
080    /**
081     * Returns the index (zero based) of the first result to include. Useful for paging.
082     *
083     * @return the first index
084     */
085    long getFirstResult();
086
087    /**
088     * Sets the index (zero based) of the first result to include. Useful for paging.
089     *
090     * @param firstResult the first index
091     */
092    void setFirstResult( int firstResult );
093
094    /**
095     * Returns the maximum number of users to return.
096     *
097     * @return the maximum number of users to return.
098     */
099    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}