View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.security.api;
23  
24  import java.util.ArrayList;
25  import java.util.Collection;
26  import java.util.List;
27  
28  import javax.xml.bind.annotation.XmlAccessType;
29  import javax.xml.bind.annotation.XmlAccessorType;
30  import javax.xml.bind.annotation.XmlElement;
31  import javax.xml.bind.annotation.XmlRootElement;
32  import javax.xml.bind.annotation.XmlType;
33  
34  /**
35   * A wrapper for user collections.
36   */
37  @XmlAccessorType(XmlAccessType.NONE)
38  @XmlType(name = "users", namespace = "http://org.opencastproject.security")
39  @XmlRootElement(name = "users", namespace = "http://org.opencastproject.security")
40  public class JaxbUserList {
41  
42    /** A list of users. */
43    @XmlElement(name = "user")
44    protected List<JaxbUser> users = new ArrayList<JaxbUser>();
45  
46    public JaxbUserList() {
47    }
48  
49    public JaxbUserList(JaxbUser user) {
50      users.add(user);
51    }
52  
53    public JaxbUserList(Collection<JaxbUser> users) {
54      for (JaxbUser user : users)
55        this.users.add(user);
56    }
57  
58    /**
59     * @return the users
60     */
61    public List<JaxbUser> getUsers() {
62      return users;
63    }
64  
65    /**
66     * @param users
67     *          the users to set
68     */
69    public void setUsers(List<JaxbUser> users) {
70      this.users = users;
71    }
72  
73    public void add(User user) {
74      if (user instanceof JaxbUser) {
75        users.add((JaxbUser) user);
76      } else {
77        users.add(JaxbUser.fromUser(user));
78      }
79    }
80  
81  }