BrightSide Workbench Full Report + Source Code
SecItem.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 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.security;
20 
21 import java.util.Objects;
22 import org.turro.util.CompareUtil;
23 
28 public class SecItem implements Comparable<SecItem> {
29 
30  private final String secName;
31  private final long usage;
32  private boolean selected;
33  private boolean sibling;
34 
35  public SecItem(String secName, long usage) {
36  this.secName = secName;
37  this.usage = usage;
38  this.selected = false;
39  }
40 
41  public String getSecName() {
42  return secName;
43  }
44 
45  public long getUsage() {
46  return usage;
47  }
48 
49  @Override
50  public int compareTo(SecItem o) {
51  return CompareUtil.compare(secName, o.secName);
52  }
53 
54  public boolean isSelected() {
55  return selected;
56  }
57 
58  public void setSelected(boolean selected) {
59  this.selected = selected;
60  }
61 
62  public boolean isSibling() {
63  return sibling;
64  }
65 
66  public void setSibling(boolean sibling) {
67  this.sibling = sibling;
68  }
69 
70  @Override
71  public String toString() {
72  return secName;
73  }
74 
75  @Override
76  public int hashCode() {
77  int hash = 7;
78  hash = 59 * hash + Objects.hashCode(this.secName);
79  return hash;
80  }
81 
82  @Override
83  public boolean equals(Object obj) {
84  if (this == obj) {
85  return true;
86  }
87  if (obj == null) {
88  return false;
89  }
90  if (getClass() != obj.getClass()) {
91  return false;
92  }
93  final SecItem other = (SecItem) obj;
94  if (!Objects.equals(this.secName, other.secName)) {
95  return false;
96  }
97  return true;
98  }
99 
100 }
void setSibling(boolean sibling)
Definition: SecItem.java:66
boolean equals(Object obj)
Definition: SecItem.java:83
int compareTo(SecItem o)
Definition: SecItem.java:50
SecItem(String secName, long usage)
Definition: SecItem.java:35
void setSelected(boolean selected)
Definition: SecItem.java:58