This repository has been archived by the owner on May 3, 2023. It is now read-only.
generated from bcgov/quickstart-openshift
-
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.
refactor: using immutability wherever it's possible
- Loading branch information
1 parent
ba09450
commit c25a663
Showing
23 changed files
with
101 additions
and
535 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
71 changes: 0 additions & 71 deletions
71
src/main/java/ca/bc/gov/backendstartapi/dto/ExampleDto.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,57 +1,11 @@ | ||
package ca.bc.gov.backendstartapi.dto; | ||
|
||
import ca.bc.gov.backendstartapi.response.BaseResponse; | ||
import ca.bc.gov.backendstartapi.util.Empty; | ||
import ca.bc.gov.backendstartapi.util.ObjectUtil; | ||
import java.util.Objects; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
/** This class represents a User data transition object. */ | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class UserDto implements BaseResponse, Empty { | ||
|
||
@Size(min = 2, max = 20) | ||
@NotBlank | ||
private String firstName; | ||
|
||
@Size(min = 2, max = 20) | ||
@NotBlank | ||
private String lastName; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
UserDto userDto = (UserDto) o; | ||
return firstName.equals(userDto.firstName) && lastName.equals(userDto.lastName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(firstName, lastName); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String template = "UserDto{firstName='%s', lastName='%s'}"; | ||
return String.format(template, firstName, lastName); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return ObjectUtil.isEmptyOrNull(firstName) | ||
&& ObjectUtil.isEmptyOrNull(lastName); | ||
} | ||
} | ||
public record UserDto( | ||
@Size(min = 2, max = 20) @NotBlank String firstName, | ||
@Size(min = 2, max = 20) @NotBlank String lastName) | ||
implements BaseResponse {} |
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
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
14 changes: 0 additions & 14 deletions
14
src/main/java/ca/bc/gov/backendstartapi/exception/EmptyObjectNotSupportedException.java
This file was deleted.
Oops, something went wrong.
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
30 changes: 1 addition & 29 deletions
30
src/main/java/ca/bc/gov/backendstartapi/response/ExceptionResponse.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 |
---|---|---|
@@ -1,32 +1,4 @@ | ||
package ca.bc.gov.backendstartapi.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** This class represents any kind of exception that this API may go through. */ | ||
@Getter | ||
@Setter | ||
@JsonInclude(Include.NON_EMPTY) | ||
public class ExceptionResponse { | ||
|
||
private static final String MESSAGE_TEMPLATE = "%d field(s) with validation problem!"; | ||
private String errorMessage; | ||
private List<FieldExceptionResponse> fields; | ||
|
||
public ExceptionResponse() { | ||
this(1); | ||
} | ||
|
||
public ExceptionResponse(int issuesCount) { | ||
this(String.format(MESSAGE_TEMPLATE, issuesCount)); | ||
} | ||
|
||
public ExceptionResponse(String errorMessage) { | ||
this.errorMessage = errorMessage; | ||
this.fields = new ArrayList<>(); | ||
} | ||
} | ||
public record ExceptionResponse(String errorMessage) {} |
17 changes: 0 additions & 17 deletions
17
src/main/java/ca/bc/gov/backendstartapi/response/FieldExceptionResponse.java
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/main/java/ca/bc/gov/backendstartapi/response/FieldIssue.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,3 @@ | ||
package ca.bc.gov.backendstartapi.response; | ||
|
||
record FieldIssue(String fieldName, String fieldMessage) {} |
Oops, something went wrong.