BrightSide Workbench Full Report + Source Code
SocialGroupValue.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.social;
20 
21 import java.util.Objects;
22 import org.turro.i18n.I_;
23 import org.turro.security.SecurityGroupType;
24 import org.turro.util.Comparison;
25 
30 public class SocialGroupValue implements Comparable<SocialGroupValue> {
31 
32  private final String name, key;
33  private final SecurityGroupType type;
34 
35  public SocialGroupValue(String name, String key, SecurityGroupType type) {
36  this.name = I_.get(name);
37  this.key = key;
38  this.type = type;
39  }
40 
41  public String getName() {
42  return name;
43  }
44 
45  public String getKey() {
46  return key;
47  }
48 
50  return type;
51  }
52 
53  @Override
54  public int compareTo(SocialGroupValue o) {
55  return Comparison.ascendant()
56  .compare(type.getSortOrder(), o.type.getSortOrder())
57  .compare(name, o.name)
58  .get();
59  }
60 
61  @Override
62  public int hashCode() {
63  int hash = 7;
64  hash = 31 * hash + Objects.hashCode(this.key);
65  return hash;
66  }
67 
68  @Override
69  public boolean equals(Object obj) {
70  if (this == obj) {
71  return true;
72  }
73  if (obj == null) {
74  return false;
75  }
76  if (getClass() != obj.getClass()) {
77  return false;
78  }
79  final SocialGroupValue other = (SocialGroupValue) obj;
80  return Objects.equals(this.key, other.key);
81  }
82 
83 }
SocialGroupValue(String name, String key, SecurityGroupType type)
static String get(String msg)
Definition: I_.java:41