BrightSide Workbench Full Report + Source Code
InterestCategory.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2024 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.interest;
20 
21 import java.util.Objects;
22 import org.turro.participation.ParticipationReason;
23 
28 public class InterestCategory {
29 
30  private final ParticipationReason reason;
31  private final boolean reversed;
32 
33  public InterestCategory(ParticipationReason reason, boolean reversed) {
34  this.reason = reason;
35  this.reversed = reversed;
36  }
37 
39  return reason;
40  }
41 
42  public boolean isReversed() {
43  return reversed;
44  }
45 
46  public String getLabel() {
47  return switch(reason) {
48  case REASON_SEEN -> "Seen";
49  case REASON_ADHERE -> "Adhered to";
50  case REASON_APPLY -> "Applied to";
51  case REASON_FOLLOW -> reversed ? "Followers" : "Following";
52  case REASON_INFO -> "Information";
53  case REASON_LIKE -> reversed ? "Liked me" : "Liked";
54  case REASON_PARTICIPATE -> "Participating";
55  case REASON_SPAM -> "Marked as SPAM";
56  default -> "**";
57  };
58  }
59 
60  public String getIcon() {
61  return switch(reason) {
62  case REASON_SEEN -> "eye";
63  case REASON_ADHERE -> "sticky note";
64  case REASON_APPLY -> "hand point up";
65  case REASON_FOLLOW -> reversed ? "user friends" : "user friends";
66  case REASON_INFO -> "info";
67  case REASON_LIKE -> reversed ? "thumbs up" : "thumbs up";
68  case REASON_PARTICIPATE -> "users cog";
69  case REASON_SPAM -> "comment slash";
70  default -> "question";
71  };
72  }
73 
74  /* Utils */
75 
76  @Override
77  public int hashCode() {
78  int hash = 3;
79  hash = 67 * hash + Objects.hashCode(this.reason);
80  hash = 67 * hash + (this.reversed ? 1 : 0);
81  return hash;
82  }
83 
84  @Override
85  public boolean equals(Object obj) {
86  if (this == obj) {
87  return true;
88  }
89  if (obj == null) {
90  return false;
91  }
92  if (getClass() != obj.getClass()) {
93  return false;
94  }
95  final InterestCategory other = (InterestCategory) obj;
96  if (this.reversed != other.reversed) {
97  return false;
98  }
99  return this.reason == other.reason;
100  }
101 
102 }
InterestCategory(ParticipationReason reason, boolean reversed)