Skip to content

Commit 4c6d7e5

Browse files
msailescarlzogh
andauthored
Added default IntelliJ equals, hashCode and toString methods. (#248)
Co-authored-by: Carl Zogheib <[email protected]>
1 parent 477d3b0 commit 4c6d7e5

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2WebSocketEvent.java

+50-49
Original file line numberDiff line numberDiff line change
@@ -663,64 +663,65 @@ public void setIsBase64Encoded(boolean isBase64Encoded) {
663663
}
664664

665665
@Override
666-
public int hashCode() {
667-
int hash = 7;
668-
669-
hash = 43 * hash + Objects.hashCode(this.requestContext);
670-
hash = 43 * hash + Objects.hashCode(this.body);
671-
hash = 43 * hash + (this.isBase64Encoded ? 1 : 0);
672-
673-
return hash;
674-
}
675-
676-
@Override
677-
public boolean equals(Object obj) {
678-
if (this == obj) {
679-
return true;
680-
}
681-
682-
if (obj == null) {
666+
public boolean equals(Object o) {
667+
if (this == o) return true;
668+
if (o == null || getClass() != o.getClass()) return false;
669+
670+
APIGatewayV2WebSocketEvent that = (APIGatewayV2WebSocketEvent) o;
671+
672+
if (isBase64Encoded != that.isBase64Encoded) return false;
673+
if (resource != null ? !resource.equals(that.resource) : that.resource != null) return false;
674+
if (path != null ? !path.equals(that.path) : that.path != null) return false;
675+
if (httpMethod != null ? !httpMethod.equals(that.httpMethod) : that.httpMethod != null) return false;
676+
if (headers != null ? !headers.equals(that.headers) : that.headers != null) return false;
677+
if (multiValueHeaders != null ? !multiValueHeaders.equals(that.multiValueHeaders) : that.multiValueHeaders != null)
683678
return false;
684-
}
685-
686-
if (getClass() != obj.getClass()) {
679+
if (queryStringParameters != null ? !queryStringParameters.equals(that.queryStringParameters) : that.queryStringParameters != null)
687680
return false;
688-
}
689-
690-
final APIGatewayV2WebSocketEvent other = (APIGatewayV2WebSocketEvent) obj;
691-
692-
if (this.isBase64Encoded != other.isBase64Encoded) {
681+
if (multiValueQueryStringParameters != null ? !multiValueQueryStringParameters.equals(that.multiValueQueryStringParameters) : that.multiValueQueryStringParameters != null)
693682
return false;
694-
}
695-
696-
if (!Objects.equals(this.body, other.body)) {
683+
if (pathParameters != null ? !pathParameters.equals(that.pathParameters) : that.pathParameters != null)
697684
return false;
698-
}
699-
700-
if (!Objects.equals(this.requestContext, other.requestContext)) {
685+
if (stageVariables != null ? !stageVariables.equals(that.stageVariables) : that.stageVariables != null)
701686
return false;
702-
}
703-
return true;
687+
if (requestContext != null ? !requestContext.equals(that.requestContext) : that.requestContext != null)
688+
return false;
689+
return body != null ? body.equals(that.body) : that.body == null;
704690
}
705691

706692
@Override
707-
public String toString() {
708-
StringBuilder sb = new StringBuilder();
709-
sb.append("{");
710-
711-
if (requestContext != null) {
712-
sb.append("requestContext: ").append(requestContext).append(",");
713-
}
714-
715-
if (body != null) {
716-
sb.append("body: ").append(body).append(",");
717-
}
718-
719-
sb.append("isBase64Encoded: ").append(isBase64Encoded).append(",");
720-
721-
sb.append("}");
693+
public int hashCode() {
694+
int result = resource != null ? resource.hashCode() : 0;
695+
result = 31 * result + (path != null ? path.hashCode() : 0);
696+
result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0);
697+
result = 31 * result + (headers != null ? headers.hashCode() : 0);
698+
result = 31 * result + (multiValueHeaders != null ? multiValueHeaders.hashCode() : 0);
699+
result = 31 * result + (queryStringParameters != null ? queryStringParameters.hashCode() : 0);
700+
result = 31 * result + (multiValueQueryStringParameters != null ? multiValueQueryStringParameters.hashCode() : 0);
701+
result = 31 * result + (pathParameters != null ? pathParameters.hashCode() : 0);
702+
result = 31 * result + (stageVariables != null ? stageVariables.hashCode() : 0);
703+
result = 31 * result + (requestContext != null ? requestContext.hashCode() : 0);
704+
result = 31 * result + (body != null ? body.hashCode() : 0);
705+
result = 31 * result + (isBase64Encoded ? 1 : 0);
706+
return result;
707+
}
722708

709+
@Override
710+
public String toString() {
711+
final StringBuilder sb = new StringBuilder("APIGatewayV2WebSocketEvent{");
712+
sb.append("resource='").append(resource).append('\'');
713+
sb.append(", path='").append(path).append('\'');
714+
sb.append(", httpMethod='").append(httpMethod).append('\'');
715+
sb.append(", headers=").append(headers);
716+
sb.append(", multiValueHeaders=").append(multiValueHeaders);
717+
sb.append(", queryStringParameters=").append(queryStringParameters);
718+
sb.append(", multiValueQueryStringParameters=").append(multiValueQueryStringParameters);
719+
sb.append(", pathParameters=").append(pathParameters);
720+
sb.append(", stageVariables=").append(stageVariables);
721+
sb.append(", requestContext=").append(requestContext);
722+
sb.append(", body='").append(body).append('\'');
723+
sb.append(", isBase64Encoded=").append(isBase64Encoded);
724+
sb.append('}');
723725
return sb.toString();
724726
}
725-
726727
}

0 commit comments

Comments
 (0)