Skip to content

Commit

Permalink
Merge pull request #221 from /issues/220-rest-model-toString-equals
Browse files Browse the repository at this point in the history
Fix #220: ToString and Equals for ObjectResponse and ObjectRequest
  • Loading branch information
banterCZ authored Oct 24, 2023
2 parents 5d338b4 + e6f7a4b commit ab97a0c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@


import jakarta.validation.constraints.NotBlank;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
* Transport object for RESTful API representing an error instance.
*
* @author Petr Dvorak, [email protected]
*/
@ToString
@EqualsAndHashCode
public class Error {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
* Simple class representing a request with an object.
Expand All @@ -26,6 +28,8 @@
*
* @param <T> Type of the request object.
*/
@ToString
@EqualsAndHashCode
public class ObjectRequest<T> {

@Valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
* Generic response with status and object of a custom class.
Expand All @@ -26,6 +28,8 @@
*
* @param <T> Type of the response object
*/
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class ObjectResponse<T> extends Response {

@Valid
Expand All @@ -36,7 +40,7 @@ public class ObjectResponse<T> extends Response {
* Default constructor
*/
public ObjectResponse() {
this.status = Status.OK;
super(Status.OK);
}

/**
Expand All @@ -45,7 +49,7 @@ public ObjectResponse() {
* @param responseObject Response object.
*/
public ObjectResponse(T responseObject) {
this.status = Status.OK;
super(Status.OK);
this.responseObject = responseObject;
}

Expand All @@ -56,28 +60,10 @@ public ObjectResponse(T responseObject) {
* @param responseObject Response object.
*/
public ObjectResponse(String status, T responseObject) {
this.status = status;
super(status);
this.responseObject = responseObject;
}

/**
* Get response status.
*
* @return Response status.
*/
public String getStatus() {
return status;
}

/**
* Set response status.
*
* @param status Response status.
*/
public void setStatus(String status) {
this.status = status;
}

/**
* Get response object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@


import jakarta.validation.constraints.NotBlank;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
* Simple status only response object.
*
* @author Petr Dvorak, [email protected]
*/
@EqualsAndHashCode
@ToString
public class Response {

/**
Expand All @@ -46,7 +50,7 @@ public static class Status {
* Response status.
*/
@NotBlank
protected String status;
private String status;

/**
* Default constructor.
Expand Down

0 comments on commit ab97a0c

Please sign in to comment.