BrightSide Workbench Full Report + Source Code
EntityParticipationPK.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.entities.db;
20 
21 import java.io.Serializable;
22 import java.util.Objects;
23 import org.turro.participation.ParticipationReason;
24 import org.turro.path.ComplexNode;
25 
30 public class EntityParticipationPK implements Serializable {
31 
32  private String entityPath;
33  private String participatorPath;
34  private ParticipationReason reason;
35 
36  public String getEntityPath() {
37  return entityPath;
38  }
39 
40  public void setEntityPath(String entityPath) {
41  this.entityPath = entityPath;
42  }
43 
44  public String getParticipatorPath() {
45  return participatorPath;
46  }
47 
48  public void setParticipatorPath(String participatorPath) {
49  this.participatorPath = participatorPath;
50  }
51 
53  return reason;
54  }
55 
56  public void setReason(ParticipationReason reason) {
57  this.reason = reason;
58  }
59 
60  /* Id utils */
61 
62  public static EntityParticipationPK from(String id) {
63  return from(ComplexNode.complex(id));
64  }
65 
66  public static EntityParticipationPK from(ComplexNode id) {
68  epk.entityPath = id.node(0);
69  epk.participatorPath = id.node(1);
70  epk.reason = ParticipationReason.valueOf(id.node(2));
71  return epk;
72  }
73 
74  /* hashcode & equals */
75 
76  @Override
77  public int hashCode() {
78  int hash = 7;
79  hash = 59 * hash + Objects.hashCode(this.entityPath);
80  hash = 59 * hash + Objects.hashCode(this.participatorPath);
81  hash = 59 * hash + Objects.hashCode(this.reason);
82  return hash;
83  }
84 
85  @Override
86  public boolean equals(Object obj) {
87  if (this == obj) {
88  return true;
89  }
90  if (obj == null) {
91  return false;
92  }
93  if (getClass() != obj.getClass()) {
94  return false;
95  }
96  final EntityParticipationPK other = (EntityParticipationPK) obj;
97  if (!Objects.equals(this.entityPath, other.entityPath)) {
98  return false;
99  }
100  if (!Objects.equals(this.participatorPath, other.participatorPath)) {
101  return false;
102  }
103  if (this.reason != other.reason) {
104  return false;
105  }
106  return true;
107  }
108 
109 }
static EntityParticipationPK from(ComplexNode id)