blob: d74ccfb9a2e06e67bf266d3c82b2607fb5c272cd [file] [log] [blame]
Matthias Andreas Benkard2f0b3702020-01-12 15:46:34 +01001package eu.mulk.entity;
2
3import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
4import java.util.Collection;
5import java.util.Objects;
6import javax.persistence.Basic;
7import javax.persistence.Column;
8import javax.persistence.Entity;
9import javax.persistence.Id;
10import javax.persistence.OneToMany;
11import javax.persistence.Table;
12
13@Entity
14@Table(name = "categories", schema = "public", catalog = "mulkcms")
15public class Category extends PanacheEntityBase {
16
17 private int id;
18 private String name;
19 private Collection<CategoryInclusion> supercategories;
20 private Collection<CategoryInclusion> subcategories;
21
22 @Id
23 @Column(name = "id", nullable = false)
24 public int getId() {
25 return id;
26 }
27
28 public void setId(int id) {
29 this.id = id;
30 }
31
32 @Basic
33 @Column(name = "name", nullable = false, length = -1)
34 public String getName() {
35 return name;
36 }
37
38 public void setName(String name) {
39 this.name = name;
40 }
41
42 @Override
43 public boolean equals(Object o) {
44 if (this == o) {
45 return true;
46 }
47 if (o == null || getClass() != o.getClass()) {
48 return false;
49 }
50 Category category = (Category) o;
51 return id == category.id &&
52 Objects.equals(name, category.name);
53 }
54
55 @Override
56 public int hashCode() {
57 return Objects.hash(id, name);
58 }
59
60 @OneToMany(mappedBy = "subcategory")
61 public Collection<CategoryInclusion> getSupercategories() {
62 return supercategories;
63 }
64
65 public void setSupercategories(Collection<CategoryInclusion> supercategories) {
66 this.supercategories = supercategories;
67 }
68
69 @OneToMany(mappedBy = "supercategory")
70 public Collection<CategoryInclusion> getSubcategories() {
71 return subcategories;
72 }
73
74 public void setSubcategories(Collection<CategoryInclusion> subcategories) {
75 this.subcategories = subcategories;
76 }
77}