Skip to contentPackage: RoleImpl
RoleImpl
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.authorization.role.shiro;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntity;
17: import org.eclipse.kapua.model.id.KapuaId;
18: import org.eclipse.kapua.service.authorization.role.Role;
19:
20: import javax.persistence.Entity;
21: import javax.persistence.Table;
22:
23: /**
24: * {@link Role} implementation.
25: *
26: * @since 1.0.0
27: */
28: @Entity(name = "Role")
29: @Table(name = "athz_role")
30: public class RoleImpl extends AbstractKapuaNamedEntity implements Role {
31:
32: private static final long serialVersionUID = -3760818776351242930L;
33:
34: protected RoleImpl() {
35: super();
36: }
37:
38: /**
39: * Constructor.
40: *
41: * @param scopeId The scope {@link KapuaId}
42: * @since 1.0.0
43: */
44: public RoleImpl(KapuaId scopeId) {
45: super(scopeId);
46: }
47:
48: /**
49: * Clone constructor.
50: *
51: * @param role The {@link Role} to clone
52: * @throws KapuaException
53: * @since 1.0.0
54: */
55: public RoleImpl(Role role) throws KapuaException {
56: super(role);
57: }
58:
59: @Override
60: public int hashCode() {
61: final int prime = 31;
62: int result = 1;
63:• result = prime * result + (name == null ? 0 : name.hashCode());
64: return result;
65: }
66:
67: @Override
68: public boolean equals(Object obj) {
69:• if (this == obj) {
70: return true;
71: }
72:• if (obj == null) {
73: return false;
74: }
75:• if (getClass() != obj.getClass()) {
76: return false;
77: }
78: RoleImpl other = (RoleImpl) obj;
79:• if (name == null) {
80:• if (other.name != null) {
81: return false;
82: }
83:• } else if (!name.equals(other.name)) {
84: return false;
85: }
86: return true;
87: }
88: }