View Javadoc
1   package io.oasp.module.security.common.api.accesscontrol;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   import java.util.Objects;
6   
7   import javax.xml.bind.annotation.XmlAccessType;
8   import javax.xml.bind.annotation.XmlAccessorType;
9   import javax.xml.bind.annotation.XmlElement;
10  import javax.xml.bind.annotation.XmlRootElement;
11  
12  /**
13   * This class represents the security configuration for the mapping of {@link AccessControlGroup}s to
14   * {@link AccessControlPermission}s. Everything is properly annotated for JAXB (de)serialization from/to XML.
15   *
16   * @author hohwille
17   */
18  @XmlAccessorType(XmlAccessType.FIELD)
19  @XmlRootElement(name = "access-control-schema")
20  public class AccessControlSchema {
21  
22    /** @see #getGroups() */
23    @XmlElement(name = "group")
24    private List<AccessControlGroup> groups;
25  
26    /**
27     * The constructor.
28     */
29    public AccessControlSchema() {
30  
31      super();
32    }
33  
34    /**
35     * @return the {@link List} of {@link AccessControlGroup}s contained in this {@link AccessControlSchema}.
36     */
37    public List<AccessControlGroup> getGroups() {
38  
39      if (this.groups == null) {
40        this.groups = new ArrayList<>();
41      }
42      return this.groups;
43    }
44  
45    /**
46     * @param groups the new {@link #getGroups() groups}.
47     */
48    public void setGroups(List<AccessControlGroup> groups) {
49  
50      this.groups = groups;
51    }
52  
53    @Override
54    public int hashCode() {
55  
56      final int prime = 31;
57      int result = 1;
58      result = prime * result + ((this.groups == null) ? 0 : this.groups.hashCode());
59      return result;
60    }
61  
62    @Override
63    public boolean equals(Object obj) {
64  
65      if (this == obj) {
66        return true;
67      }
68      if (obj == null) {
69        return false;
70      }
71      if (getClass() != obj.getClass()) {
72        return false;
73      }
74      AccessControlSchema other = (AccessControlSchema) obj;
75      if (!Objects.equals(this.groups, other.groups)) {
76        return false;
77      }
78      return true;
79    }
80  
81  }