Skip to content

Commit 95605f4

Browse files
committed
feat: create product entity
Signed-off-by: Otavio Santana <[email protected]>
1 parent 5a34716 commit 95605f4

File tree

1 file changed

+54
-1
lines changed
  • src/main/java/org/soujava/demos/mongodb/document

1 file changed

+54
-1
lines changed
Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,57 @@
11
package org.soujava.demos.mongodb.document;
22

3+
import jakarta.json.bind.annotation.JsonbVisibility;
4+
import jakarta.nosql.Column;
5+
import jakarta.nosql.Convert;
6+
import jakarta.nosql.Entity;
7+
import jakarta.nosql.Id;
8+
import org.eclipse.jnosql.databases.mongodb.mapping.ObjectIdConverter;
9+
10+
import java.util.List;
11+
import java.util.Objects;
12+
import java.util.Set;
13+
14+
@Entity
315
public class Product {
4-
}
16+
17+
@Id
18+
@Convert(ObjectIdConverter.class)
19+
private String id;
20+
21+
@Column
22+
private String name;
23+
24+
@Column
25+
private Manufacturer manufacturer;
26+
27+
@Column
28+
private List<String> tags;
29+
30+
@Column
31+
private Set<Category> categories;
32+
33+
@Override
34+
public boolean equals(Object o) {
35+
if (o == null || getClass() != o.getClass()) {
36+
return false;
37+
}
38+
Product product = (Product) o;
39+
return Objects.equals(id, product.id);
40+
}
41+
42+
@Override
43+
public int hashCode() {
44+
return Objects.hashCode(id);
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "Product{" +
50+
"id='" + id + '\'' +
51+
", name='" + name + '\'' +
52+
", manufacturer=" + manufacturer +
53+
", tags=" + tags +
54+
", categories=" + categories +
55+
'}';
56+
}
57+
}

0 commit comments

Comments
 (0)