From 52c30f894e9454f44c4330c18e45936032112b6c Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Mon, 16 Oct 2023 13:30:35 +0200 Subject: [PATCH] Fix compatibility issues --- .../pycharm/pylint/checker/Problem.java | 85 +++++++++---------- .../leinardi/pycharm/pylint/plapi/Issue.java | 13 +-- 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/leinardi/pycharm/pylint/checker/Problem.java b/src/main/java/com/leinardi/pycharm/pylint/checker/Problem.java index feead1f..7be1f74 100644 --- a/src/main/java/com/leinardi/pycharm/pylint/checker/Problem.java +++ b/src/main/java/com/leinardi/pycharm/pylint/checker/Problem.java @@ -22,11 +22,10 @@ import com.intellij.psi.PsiElement; import com.leinardi.pycharm.pylint.PylintBundle; import com.leinardi.pycharm.pylint.plapi.SeverityLevel; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + public class Problem { private final PsiElement target; private final SeverityLevel severityLevel; @@ -103,53 +102,51 @@ public boolean isSuppressErrors() { @Override public String toString() { - return new ToStringBuilder(this) - .append("target", target) - .append("message", message) - .append("messageId", messageId) - .append("severityLevel", severityLevel) - .append("line", line) - .append("column", column) - .append("symbol", symbol) - .append("afterEndOfLine", afterEndOfLine) - .append("suppressErrors", suppressErrors) - .toString(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .append(target) - .append(message) - .append(messageId) - .append(severityLevel) - .append(line) - .append(column) - .append(symbol) - .append(afterEndOfLine) - .append(suppressErrors) - .toHashCode(); + return "Problem{" + + "target=" + target + + ", severityLevel=" + severityLevel + + ", line=" + line + + ", column=" + column + + ", symbol='" + symbol + '\'' + + ", message='" + message + '\'' + + ", messageId='" + messageId + '\'' + + ", afterEndOfLine=" + afterEndOfLine + + ", suppressErrors=" + suppressErrors + + '}'; } @Override - public boolean equals(Object other) { - if (other == this) { + public boolean equals(Object o) { + if (this == o) { return true; } - if (!(other instanceof Problem)) { + if (!(o instanceof Problem)) { return false; } - Problem rhs = ((Problem) other); - return new EqualsBuilder() - .append(target, rhs.target) - .append(message, rhs.message) - .append(messageId, rhs.messageId) - .append(severityLevel, rhs.severityLevel) - .append(line, rhs.line) - .append(column, rhs.column) - .append(symbol, rhs.symbol) - .append(afterEndOfLine, rhs.afterEndOfLine) - .append(suppressErrors, rhs.suppressErrors) - .isEquals(); + Problem problem = (Problem) o; + return line == problem.line && + column == problem.column && + afterEndOfLine == problem.afterEndOfLine && + suppressErrors == problem.suppressErrors && + Objects.equals(target, problem.target) && + severityLevel == problem.severityLevel && + Objects.equals(symbol, problem.symbol) && + Objects.equals(message, problem.message) && + Objects.equals(messageId, problem.messageId); + } + + @Override + public int hashCode() { + return Objects.hash( + target, + severityLevel, + line, + column, + symbol, + message, + messageId, + afterEndOfLine, + suppressErrors + ); } } diff --git a/src/main/java/com/leinardi/pycharm/pylint/plapi/Issue.java b/src/main/java/com/leinardi/pycharm/pylint/plapi/Issue.java index b458ceb..e665b44 100644 --- a/src/main/java/com/leinardi/pycharm/pylint/plapi/Issue.java +++ b/src/main/java/com/leinardi/pycharm/pylint/plapi/Issue.java @@ -17,7 +17,6 @@ package com.leinardi.pycharm.pylint.plapi; import com.squareup.moshi.Json; -import org.apache.commons.lang.builder.HashCodeBuilder; import java.util.Objects; @@ -134,17 +133,7 @@ public String toString() { @Override public int hashCode() { - return new HashCodeBuilder() - .append(message) - .append(module) - .append(symbol) - .append(path) - .append(column) - .append(line) - .append(obj) - .append(messageId) - .append(severityLevel) - .toHashCode(); + return Objects.hash(severityLevel, module, obj, line, column, path, symbol, message, messageId); } @Override