-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
- Loading branch information
1 parent
8fcf628
commit 6ffc655
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.otaviojava.demos.ddd; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Embeddable; | ||
|
||
@Embeddable(Embeddable.EmbeddableType.GROUPING) | ||
public record Category(@Column String name, @Column String description) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.otaviojava.demos.ddd; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Embeddable; | ||
|
||
|
||
@Embeddable(Embeddable.EmbeddableType.GROUPING) | ||
public record Manufacturer(@Column String name, @Column String address, @Column String contactNumber) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.otaviojava.demos.ddd; | ||
|
||
import jakarta.json.bind.annotation.JsonbVisibility; | ||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Convert; | ||
import jakarta.nosql.Entity; | ||
import jakarta.nosql.Id; | ||
import org.eclipse.jnosql.databases.mongodb.mapping.ObjectIdConverter; | ||
import org.soujava.samples.mongodb.products.infra.FieldVisibilityStrategy; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
@Entity | ||
@JsonbVisibility(FieldVisibilityStrategy.class) | ||
public class Product { | ||
|
||
@Id | ||
@Convert(ObjectIdConverter.class) | ||
private String id; | ||
|
||
@Column | ||
private String name; | ||
|
||
@Column | ||
private Manufacturer manufacturer; | ||
|
||
@Column | ||
private List<String> tags; | ||
|
||
@Column | ||
private Set<Category> categories; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Product product = (Product) o; | ||
return Objects.equals(id, product.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Product{" + | ||
"id='" + id + '\'' + | ||
", name='" + name + '\'' + | ||
", manufacturer=" + manufacturer + | ||
", tags=" + tags + | ||
", categories=" + categories + | ||
'}'; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/otaviojava/demos/ddd/ProductRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.otaviojava.demos.ddd; | ||
|
||
import jakarta.data.repository.BasicRepository; | ||
import jakarta.data.repository.Repository; | ||
|
||
@Repository | ||
public interface ProductRepository extends BasicRepository<Product, String> { | ||
} |