diff --git a/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/BaseCaseStyle.java b/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/BaseCaseStyle.java index 19c86a7..a1bfa3c 100644 --- a/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/BaseCaseStyle.java +++ b/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/BaseCaseStyle.java @@ -34,30 +34,16 @@ public abstract class BaseCaseStyle implements CaseStyle { @Override public boolean equals(@Nullable Object obj) { - if (obj == null) { - return false; - } - if (obj instanceof CaseStyle caseStyle) { - return equals(caseStyle); - } else { - return false; - } - } - /** - * Determines equality based on the {@link #getName()} method. - * - * @param otherCaseStyle the object to compare with - * @return true if the given object is a {@code CaseStyle} with the same name, false otherwise - */ - public boolean equals(@Nullable final CaseStyle otherCaseStyle) { - if (this == otherCaseStyle) { + if (this == obj) { return true; } - if (otherCaseStyle == null || getClass() != otherCaseStyle.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } - return getName().equals(otherCaseStyle.getName()); + + CaseStyle caseStyle = (CaseStyle) obj; + return getName().equals(caseStyle.getName()); } /** diff --git a/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/CaseStyle.java b/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/CaseStyle.java index 084e774..3aae360 100644 --- a/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/CaseStyle.java +++ b/stylesniffer-api/src/main/java/dev/cookiecode/stylesniffer/api/CaseStyle.java @@ -63,5 +63,11 @@ default Set getVariantNames() { return unmodifiableSet(of(getName())); } - boolean equals(@Nullable Object otherCaseStyle); + /** + * Determines equality based on the {@link #getName()} method. + * + * @param object the object to compare with + * @return true if the given object is a {@code CaseStyle} with the same name, false otherwise + */ + boolean equals(@Nullable Object object); }