BrightSide Workbench Full Report + Source Code
SkillRoot.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 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.skills;
20 
21 import java.util.Objects;
22 import org.turro.elephant.entities.db.Skill;
23 import org.turro.elephant.entities.db.SkillType;
24 
29 public class SkillRoot {
30 
31  private final String skill;
32  private final SkillType type;
33  private final boolean validated;
34  private final long usage;
35 
36  public SkillRoot(Skill skill) {
37  this(skill.getSkill(), skill.getType(), skill.isValidated(), 0);
38  }
39 
40  public SkillRoot(String skill, SkillType type, long usage) {
41  this(skill, type, false, usage);
42  }
43 
44  public SkillRoot(String skill, SkillType type, boolean validated, long usage) {
45  this.skill = skill;
46  this.type = type;
47  this.validated = validated;
48  this.usage = usage;
49  }
50 
51  public String getSkill() {
52  return skill;
53  }
54 
55  public SkillType getType() {
56  return type;
57  }
58 
59  public boolean isValidated() {
60  return validated;
61  }
62 
63  public long getUsage() {
64  return usage;
65  }
66 
67  public Skill getFor(String entityPath) {
68  Skill s = new Skill();
69  s.setEntityPath(entityPath);
70  s.setSkill(skill);
71  s.setType(type);
72  s.setValidated(validated);
73  return s;
74  }
75 
76  /* Chosenbox */
77 
78  @Override
79  public String toString() {
80  return skill;
81  }
82 
83  @Override
84  public int hashCode() {
85  int hash = 7;
86  hash = 37 * hash + Objects.hashCode(this.skill);
87  hash = 37 * hash + Objects.hashCode(this.type);
88  return hash;
89  }
90 
91  @Override
92  public boolean equals(Object obj) {
93  if (this == obj) {
94  return true;
95  }
96  if (obj == null) {
97  return false;
98  }
99  if (getClass() != obj.getClass()) {
100  return false;
101  }
102  final SkillRoot other = (SkillRoot) obj;
103  if (!Objects.equals(this.skill, other.skill)) {
104  return false;
105  }
106  if (this.type != other.type) {
107  return false;
108  }
109  return true;
110  }
111 
112 }
void setSkill(String skill)
Definition: Skill.java:47
void setType(SkillType type)
Definition: Skill.java:63
void setEntityPath(String entityPath)
Definition: Skill.java:55
void setValidated(boolean validated)
Definition: Skill.java:71
Skill getFor(String entityPath)
Definition: SkillRoot.java:67
SkillRoot(String skill, SkillType type, boolean validated, long usage)
Definition: SkillRoot.java:44
SkillRoot(String skill, SkillType type, long usage)
Definition: SkillRoot.java:40
boolean equals(Object obj)
Definition: SkillRoot.java:92