View Javadoc
1   package de.dlr.shepard.neo4Core.entities;
2   
3   import de.dlr.shepard.util.Constants;
4   import de.dlr.shepard.util.HasId;
5   import java.util.ArrayList;
6   import java.util.List;
7   import java.util.Objects;
8   import lombok.Data;
9   import lombok.NoArgsConstructor;
10  import lombok.ToString;
11  import org.neo4j.ogm.annotation.NodeEntity;
12  import org.neo4j.ogm.annotation.Relationship;
13  import org.neo4j.ogm.annotation.Relationship.Direction;
14  
15  @NodeEntity
16  @Data
17  @ToString(callSuper = true)
18  @NoArgsConstructor
19  public class UserGroup extends BasicEntity {
20  
21    @Relationship(type = Constants.IS_IN_GROUP, direction = Direction.INCOMING)
22    private List<User> users = new ArrayList<>();
23  
24    @ToString.Exclude
25    @Relationship(type = Constants.HAS_PERMISSIONS)
26    private Permissions permissions;
27  
28    public UserGroup(long id) {
29      super(id);
30    }
31  
32    @Override
33    public int hashCode() {
34      final int prime = 31;
35      int result = super.hashCode();
36      result = prime * result + Objects.hash(users);
37      result = prime * result + HasId.hashcodeHelper(permissions);
38      return result;
39    }
40  
41    @Override
42    public boolean equals(Object obj) {
43      if (this == obj) return true;
44      if (!super.equals(obj)) return false;
45      if (!(obj instanceof UserGroup)) return false;
46      UserGroup other = (UserGroup) obj;
47      return Objects.equals(users, other.users) && HasId.equalsHelper(permissions, other.permissions);
48    }
49  }