Skip to content

Commit 6ffc655

Browse files
committed
chore: include initial project code
Signed-off-by: Otavio Santana <[email protected]>
1 parent 8fcf628 commit 6ffc655

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.otaviojava.demos.ddd;
2+
3+
import jakarta.nosql.Column;
4+
import jakarta.nosql.Embeddable;
5+
6+
@Embeddable(Embeddable.EmbeddableType.GROUPING)
7+
public record Category(@Column String name, @Column String description) {
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.otaviojava.demos.ddd;
2+
3+
import jakarta.nosql.Column;
4+
import jakarta.nosql.Embeddable;
5+
6+
7+
@Embeddable(Embeddable.EmbeddableType.GROUPING)
8+
public record Manufacturer(@Column String name, @Column String address, @Column String contactNumber) {
9+
10+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.otaviojava.demos.ddd;
2+
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+
import org.soujava.samples.mongodb.products.infra.FieldVisibilityStrategy;
10+
11+
import java.util.List;
12+
import java.util.Objects;
13+
import java.util.Set;
14+
15+
@Entity
16+
@JsonbVisibility(FieldVisibilityStrategy.class)
17+
public class Product {
18+
19+
@Id
20+
@Convert(ObjectIdConverter.class)
21+
private String id;
22+
23+
@Column
24+
private String name;
25+
26+
@Column
27+
private Manufacturer manufacturer;
28+
29+
@Column
30+
private List<String> tags;
31+
32+
@Column
33+
private Set<Category> categories;
34+
35+
@Override
36+
public boolean equals(Object o) {
37+
if (o == null || getClass() != o.getClass()) {
38+
return false;
39+
}
40+
Product product = (Product) o;
41+
return Objects.equals(id, product.id);
42+
}
43+
44+
@Override
45+
public int hashCode() {
46+
return Objects.hashCode(id);
47+
}
48+
49+
@Override
50+
public String toString() {
51+
return "Product{" +
52+
"id='" + id + '\'' +
53+
", name='" + name + '\'' +
54+
", manufacturer=" + manufacturer +
55+
", tags=" + tags +
56+
", categories=" + categories +
57+
'}';
58+
}
59+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.otaviojava.demos.ddd;
2+
3+
import jakarta.data.repository.BasicRepository;
4+
import jakarta.data.repository.Repository;
5+
6+
@Repository
7+
public interface ProductRepository extends BasicRepository<Product, String> {
8+
}

0 commit comments

Comments
 (0)