From 9d7c7ea176f734dd10fdb6eb0efa40c7be56c625 Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 3 Nov 2020 21:44:17 +0100 Subject: [PATCH] Implement #equals and #hashCode for Theme. --- .../java/com/github/weisj/darklaf/theme/Theme.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java index 34842fa5..7569efc3 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java @@ -446,6 +446,20 @@ public abstract class Theme implements Comparable, Comparator { return getClass(); } + @Override + public boolean equals(final Object o) { + if (!(o instanceof Theme)) return false; + return appearsEqualTo((Theme) o); + } + + @Override + public int hashCode() { + int result = fontSizeRule != null ? fontSizeRule.hashCode() : 0; + result = 31 * result + (accentColorRule != null ? accentColorRule.hashCode() : 0); + result = 31 * result + (getThemeClass().hashCode()); + return result; + } + /** * Returns whether the appearance of the given theme is equal to the appearance if [this]. *