Commit 232282fa authored by tbilos's avatar tbilos
Browse files

Merge branch 'fix/agent-equals' of...

Merge branch 'fix/agent-equals' of gitlab.fi.muni.cz:xsmejka9/pa165-secret-archive into fix/agent-equals
parents 9681cddb 823f4c16
Pipeline #123032 waiting for manual action with stage
package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.util.ArrayList;
......@@ -12,24 +14,23 @@ import java.util.Objects;
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class Agent {
@Id
@Getter
@Setter
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany
@Getter
@Setter(AccessLevel.NONE)
private List<Skill> skills = new ArrayList<>();
@Getter
@Setter
private String training;
private String training = "";
@OneToMany
@Getter
private List<CodeName> codeNames;
@Setter(AccessLevel.NONE)
private List<CodeName> codeNames = new ArrayList<>();
@OneToMany(mappedBy = "agent")
@Getter
......@@ -43,6 +44,18 @@ public class Agent {
codeNames.add(codeName);
}
public void removeCodeName(CodeName codeName) {
codeNames.remove(codeName);
}
public void addSkill(Skill skill) {
skills.add(skill);
}
public void removeSkill(Skill skill) {
skills.remove(skill);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......@@ -55,8 +68,4 @@ public class Agent {
public int hashCode() {
return Objects.hash(getSkills(), getTraining(), getCodeNames());
}
public void addSkill(Skill skill) {
skills.add(skill);
}
}
......@@ -10,24 +10,16 @@ import java.util.Objects;
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
public class CodeName {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
@Getter
@Setter
private String codeName = "";
@ManyToOne
@Getter
@Setter
private Agent agent;
public CodeName(Agent agent, String codeName) {
this.agent = agent;
public CodeName(String codeName) {
this.codeName = codeName;
}
......@@ -38,11 +30,11 @@ public class CodeName {
if (this == o) return true;
if (!(o instanceof CodeName)) return false;
CodeName codeName1 = (CodeName) o;
return Objects.equals(getCodeName(), codeName1.getCodeName()) && Objects.equals(getAgent(), codeName1.getAgent());
return Objects.equals(getCodeName(), codeName1.getCodeName());
}
@Override
public int hashCode() {
return Objects.hash(getCodeName(), getAgent());
return Objects.hash(getCodeName());
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import cz.fi.muni.pa165.seminar4.group7.secretservice.enums.LanguageCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.Entity;
......@@ -10,10 +11,10 @@ import javax.persistence.Entity;
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class LanguageSkill extends Skill {
@Getter
@Setter
private LanguageCode languageCode;
public LanguageSkill(int level, LanguageCode languageCode) {
......
......@@ -2,6 +2,7 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.util.Objects;
......@@ -10,13 +11,22 @@ import java.util.Objects;
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public abstract class Skill {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
private int level;
public Skill(int level) {
this.level = level;
}
public Skill() { }
@Override
public boolean equals(Object o) {
if (this == o) return true;
......@@ -29,14 +39,4 @@ public abstract class Skill {
public int hashCode() {
return Objects.hash(getLevel());
}
@Getter
@Setter
private int level;
public Skill(int level) {
this.level = level;
}
public Skill() { }
}
......@@ -3,6 +3,7 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import cz.fi.muni.pa165.seminar4.group7.secretservice.enums.WeaponCategory;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.Entity;
......@@ -10,10 +11,10 @@ import javax.persistence.Entity;
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class WeaponSkill extends Skill {
@Getter
@Setter
private WeaponCategory weaponCategory;
public WeaponSkill() { }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment