1 package org.apache.fulcrum.security.util;
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.Collection;
23
24 import org.apache.fulcrum.security.entity.User;
25
26 /**
27 * This class represents a set of Users. It is based on UserSet. Hibernate
28 * doesn't return the right kind of set, so this is used to force the type of
29 * set.
30 *
31 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
32 * @version $Id$
33 */
34 public class UserSet<T extends User> extends SecuritySet<User>
35 {
36 /**
37 * Serial number
38 */
39 private static final long serialVersionUID = 4415634631270197073L;
40
41 /**
42 * Constructs an empty UserSet
43 */
44 public UserSet()
45 {
46 super();
47 }
48
49 /**
50 * Constructs a new UserSet with specified contents.
51 *
52 * If the given collection contains multiple objects that are identical WRT
53 * equals() method, some objects will be overwritten.
54 *
55 * @param users
56 * A collection of users to be contained in the set.
57 */
58 public UserSet(Collection<? extends User> users)
59 {
60 this();
61 addAll(users);
62 }
63
64 /**
65 * Returns a User with the given name, if it is contained in this UserSet.
66 *
67 * @param userName
68 * Name of User.
69 * @return User if argument matched a User in this UserSet; null if no
70 * match.
71 * @deprecated use getByName()
72 */
73 @Deprecated
74 public User getUserByName(String userName)
75 {
76 return getByName(userName);
77 }
78
79 /**
80 * Returns a User with the given id, if it is contained in this UserSet.
81 *
82 * @param userId
83 * id of the User.
84 * @return User if argument matched a User in this UserSet; null if no
85 * match.
86 * @deprecated use getById()
87 */
88 @Deprecated
89 public User getUserById(Object userId)
90 {
91 return getById(userId);
92 }
93
94 /**
95 * Print out a UserSet as a String
96 *
97 * @return The User Set as String
98 *
99 */
100 @Override
101 public String toString()
102 {
103 StringBuilder sb = new StringBuilder();
104 sb.append("UserSet: ");
105 sb.append(super.toString());
106
107 return sb.toString();
108 }
109 }