diff --git a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Firearm.java b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Firearm.java index c38173f..65942d3 100644 --- a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Firearm.java +++ b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Firearm.java @@ -140,5 +140,88 @@ public class Firearm { this.modifications.remove(modification); modification.setFirearm(null); } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private Long id; + private String name; + private FirearmType type; + private String level; + private String review; + private String calibre; + private Integer fireRate; + private Integer armourDamage; + private Integer bodyDamage; + private List modifications; + + public Builder id(Long id) { + this.id = id; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder type(FirearmType type) { + this.type = type; + return this; + } + + public Builder level(String level) { + this.level = level; + return this; + } + + public Builder review(String review) { + this.review = review; + return this; + } + + public Builder calibre(String calibre) { + this.calibre = calibre; + return this; + } + + public Builder fireRate(Integer fireRate) { + this.fireRate = fireRate; + return this; + } + + public Builder armourDamage(Integer armourDamage) { + this.armourDamage = armourDamage; + return this; + } + + public Builder bodyDamage(Integer bodyDamage) { + this.bodyDamage = bodyDamage; + return this; + } + + public Builder modifications(List modifications) { + this.modifications = modifications; + return this; + } + + public Firearm build() { + Firearm firearm = new Firearm(); + firearm.id = this.id; + firearm.name = this.name; + firearm.type = this.type; + firearm.level = this.level; + firearm.review = this.review; + firearm.calibre = this.calibre; + firearm.fireRate = this.fireRate; + firearm.armourDamage = this.armourDamage; + firearm.bodyDamage = this.bodyDamage; + firearm.modifications = this.modifications == null ? new ArrayList<>() : this.modifications; + return firearm; + } + } } diff --git a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Modification.java b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Modification.java index 6f29bd5..6ed3ec6 100644 --- a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Modification.java +++ b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/Modification.java @@ -116,5 +116,74 @@ public class Modification { public void setVideoUrl(String videoUrl) { this.videoUrl = videoUrl; } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private Long id; + private Firearm firearm; + private String name; + private String code; + private List tags; + private String note; + private String author; + private String videoUrl; + + public Builder id(Long id) { + this.id = id; + return this; + } + + public Builder firearm(Firearm firearm) { + this.firearm = firearm; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder code(String code) { + this.code = code; + return this; + } + + public Builder tags(List tags) { + this.tags = tags; + return this; + } + + public Builder note(String note) { + this.note = note; + return this; + } + + public Builder author(String author) { + this.author = author; + return this; + } + + public Builder videoUrl(String videoUrl) { + this.videoUrl = videoUrl; + return this; + } + + public Modification build() { + Modification modification = new Modification(); + modification.id = this.id; + modification.firearm = this.firearm; + modification.name = this.name; + modification.code = this.code; + modification.tags = this.tags == null ? new ArrayList<>() : this.tags; + modification.note = this.note; + modification.author = this.author; + modification.videoUrl = this.videoUrl; + return modification; + } + } } diff --git a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/User.java b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/User.java index 31cf527..67142df 100644 --- a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/User.java +++ b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/User.java @@ -70,4 +70,45 @@ public class User { this.credentials.remove(credential); credential.setUser(null); } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private Long id; + private String username; + private String email; + private List credentials; + + public Builder id(Long id) { + this.id = id; + return this; + } + + public Builder username(String username) { + this.username = username; + return this; + } + + public Builder email(String email) { + this.email = email; + return this; + } + + public Builder credentials(List credentials) { + this.credentials = credentials; + return this; + } + + public User build() { + User user = new User(); + user.id = this.id; + user.username = this.username; + user.email = this.email; + user.credentials = this.credentials == null ? new ArrayList<>() : this.credentials; + return user; + } + } } diff --git a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredential.java b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredential.java index 44e409e..b8a09a6 100644 --- a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredential.java +++ b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredential.java @@ -80,4 +80,59 @@ public class UserCredential { public void setCredential(String credential) { this.credential = credential; } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private UserCredentialId id; + private User user; + private Long userId; + private String provider; + private String credential; + + public Builder id(UserCredentialId id) { + this.id = id; + return this; + } + + public Builder user(User user) { + this.user = user; + return this; + } + + public Builder userId(Long userId) { + this.userId = userId; + return this; + } + + public Builder provider(String provider) { + this.provider = provider; + return this; + } + + public Builder credential(String credential) { + this.credential = credential; + return this; + } + + public UserCredential build() { + UserCredential userCredential = new UserCredential(); + userCredential.id = this.id == null ? new UserCredentialId() : this.id; + userCredential.user = this.user; + if (this.user != null) { + userCredential.id.setUserId(this.user.getId()); + } + if (this.userId != null) { + userCredential.id.setUserId(this.userId); + } + if (this.provider != null) { + userCredential.id.setProvider(this.provider); + } + userCredential.credential = this.credential; + return userCredential; + } + } } diff --git a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredentialId.java b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredentialId.java index ac1a98c..57a819e 100644 --- a/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredentialId.java +++ b/src/main/java/com/onixbyte/deltaforceguide/domain/entity/UserCredentialId.java @@ -44,6 +44,33 @@ public class UserCredentialId implements Serializable { public int hashCode() { return Objects.hash(userId, provider); } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private Long userId; + private String provider; + + public Builder userId(Long userId) { + this.userId = userId; + return this; + } + + public Builder provider(String provider) { + this.provider = provider; + return this; + } + + public UserCredentialId build() { + UserCredentialId id = new UserCredentialId(); + id.userId = this.userId; + id.provider = this.provider; + return id; + } + } }