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
022/**
023 * Abstract Implementation of UserQuery.
024 * Intended to be subclassed by UserManager providers.
025 */
026public abstract class AbstractUserQuery
027    implements UserQuery
028{
029
030    private String username;
031
032    private String fullName;
033
034    private String email;
035
036    private long maxResults = -1;
037
038    private long firstResult;
039
040    private String orderBy = ORDER_BY_USERNAME;
041
042    private boolean ascending = true;
043
044    public String getUsername()
045    {
046        return username;
047    }
048
049    public void setUsername( String userName )
050    {
051        this.username = userName;
052    }
053
054    public String getFullName()
055    {
056        return fullName;
057    }
058
059    public void setFullName( String fullName )
060    {
061        this.fullName = fullName;
062    }
063
064    public String getEmail()
065    {
066        return email;
067    }
068
069    public void setEmail( String email )
070    {
071        this.email = email;
072    }
073
074    public long getFirstResult()
075    {
076        return firstResult;
077    }
078
079    public void setFirstResult( int firstResult )
080    {
081        this.firstResult = firstResult;
082    }
083
084    public long getMaxResults()
085    {
086        return maxResults;
087    }
088
089    public void setMaxResults( int maxResults )
090    {
091        this.maxResults = maxResults;
092    }
093
094    public String getOrderBy()
095    {
096        return orderBy;
097    }
098
099    public void setOrderBy( String orderBy )
100    {
101        if ( orderBy == null )
102        {
103            throw new IllegalArgumentException( "orderBy cannot be set to null" );
104        }
105        else if ( !ALLOWED_ORDER_FIELDS.contains( orderBy ) )
106        {
107            throw new IllegalArgumentException( orderBy + " is not an allowed orderBy field: " + orderBy );
108        }
109        this.orderBy = orderBy;
110    }
111
112    public boolean isAscending()
113    {
114        return ascending;
115    }
116
117    public void setAscending( boolean ascending )
118    {
119        this.ascending = ascending;
120    }
121
122}