BrightSide Workbench Full Report + Source Code
TagItem.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.tags;
20 
21 import java.util.Objects;
22 import org.turro.util.CompareUtil;
23 
28 public class TagItem implements Comparable<TagItem> {
29 
30  private final String tagName;
31  private final long usage;
32  private boolean selected;
33  private boolean sibling;
34 
35  public TagItem(String tagName, long usage) {
36  this.tagName = tagName;
37  this.usage = usage;
38  this.selected = false;
39  }
40 
41  public String getTagName() {
42  return tagName;
43  }
44 
45  public long getUsage() {
46  return usage;
47  }
48 
49  @Override
50  public int compareTo(TagItem o) {
51  return CompareUtil.compare(tagName, o.tagName);
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  public TagMeta getMeta() {
71  return TagMeta.importFrom(tagName);
72  }
73 
74  @Override
75  public String toString() {
76  return tagName;
77  }
78 
79  @Override
80  public int hashCode() {
81  int hash = 7;
82  hash = 59 * hash + Objects.hashCode(this.tagName);
83  return hash;
84  }
85 
86  @Override
87  public boolean equals(Object obj) {
88  if (this == obj) {
89  return true;
90  }
91  if (obj == null) {
92  return false;
93  }
94  if (getClass() != obj.getClass()) {
95  return false;
96  }
97  final TagItem other = (TagItem) obj;
98  if (!Objects.equals(this.tagName, other.tagName)) {
99  return false;
100  }
101  return true;
102  }
103 
104 }
void setSibling(boolean sibling)
Definition: TagItem.java:66
TagItem(String tagName, long usage)
Definition: TagItem.java:35
boolean equals(Object obj)
Definition: TagItem.java:87
int compareTo(TagItem o)
Definition: TagItem.java:50
void setSelected(boolean selected)
Definition: TagItem.java:58
boolean isSelected()
Definition: TagItem.java:54
static TagMeta importFrom(String tagName)
Definition: TagMeta.java:47