BrightSide Workbench Full Report + Source Code
Duplicated.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.contacts.duplicates;
20 
21 import java.util.Collection;
22 import java.util.Set;
23 import java.util.TreeSet;
24 import org.turro.util.Comparison;
25 
30 public class Duplicated implements Comparable<Duplicated> {
31 
32  public enum DuplicatedType { STOPPER, WARNING, SAFE }
33 
34  private final DuplicatedType type;
35  private final String title, value;
36  private final Set<String> contacts = new TreeSet<>();
37 
38  private String consequence;
39 
40  public Duplicated(DuplicatedType type, String title, String value) {
41  this.type = type;
42  this.title = title;
43  this.value = value;
44  }
45 
46  public void setConsequence(String consequence) {
47  this.consequence = consequence;
48  }
49 
50  public void setContacts(Collection<String> contacts) {
51  this.contacts.addAll(contacts);
52  }
53 
55  return type;
56  }
57 
58  public String getIcon() {
59  return switch(type) {
60  case STOPPER -> "hand paper red";
61  case WARNING -> "exclamation triangle orange";
62  case SAFE -> "copy outline teal";
63  };
64  }
65 
66  public String getTitle() {
67  return title;
68  }
69 
70  public String getValue() {
71  return value;
72  }
73 
74  public String getConsequence() {
75  return consequence;
76  }
77 
78  public Set<String> getContacts() {
79  return contacts;
80  }
81 
82  @Override
83  public int compareTo(Duplicated o) {
84  return Comparison.ascendant()
85  .compare(type, o.type)
86  .compare(title, o.title)
87  .compare(value, o.value)
88  .get();
89  }
90 
91 }
Duplicated(DuplicatedType type, String title, String value)
Definition: Duplicated.java:40
void setContacts(Collection< String > contacts)
Definition: Duplicated.java:50
void setConsequence(String consequence)
Definition: Duplicated.java:46