BrightSide Workbench Full Report + Source Code
ProfilePolicy.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 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.contacts;
20 
21 import java.io.Serializable;
22 import java.util.Objects;
23 import javax.persistence.Entity;
24 import javax.persistence.Id;
25 import org.turro.string.Strings;
26 import org.turro.contacts.profile.PublishPolicy;
27 import org.turro.jpa.entity.IDaoEntity;
28 
33 @Entity
34 public class ProfilePolicy implements IDaoEntity, Serializable {
35 
36  @Id private String profilePath;
37 
38  private PublishPolicy publish;
39 
40  public String getProfilePath() {
41  return profilePath;
42  }
43 
44  public void setProfilePath(String profilePath) {
45  this.profilePath = profilePath;
46  }
47 
49  return publish;
50  }
51 
52  public void setPublish(PublishPolicy publish) {
53  this.publish = publish;
54  }
55 
56  /* IDaoEntity */
57 
58  @Override
59  public Object entityId() {
60  return profilePath;
61  }
62 
63  @Override
64  public boolean isEmpty() {
65  return Strings.isBlank(profilePath) || publish == null;
66  }
67 
68  /* Equals */
69 
70  @Override
71  public int hashCode() {
72  int hash = 3;
73  hash = 17 * hash + Objects.hashCode(this.profilePath);
74  return hash;
75  }
76 
77  @Override
78  public boolean equals(Object obj) {
79  if (this == obj) {
80  return true;
81  }
82  if (obj == null) {
83  return false;
84  }
85  if (getClass() != obj.getClass()) {
86  return false;
87  }
88  final ProfilePolicy other = (ProfilePolicy) obj;
89  if (!Objects.equals(this.profilePath, other.profilePath)) {
90  return false;
91  }
92  return true;
93  }
94 
95 }
void setPublish(PublishPolicy publish)
void setProfilePath(String profilePath)