Skip to content

Commit

Permalink
chore: include initial project code
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Dec 18, 2024
1 parent 8fcf628 commit 6ffc655
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/otaviojava/demos/ddd/Category.java
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) {
}
10 changes: 10 additions & 0 deletions src/main/java/com/otaviojava/demos/ddd/Manufacturer.java
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) {

}
59 changes: 59 additions & 0 deletions src/main/java/com/otaviojava/demos/ddd/Product.java
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 src/main/java/com/otaviojava/demos/ddd/ProductRepository.java
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> {
}

0 comments on commit 6ffc655

Please sign in to comment.