From 7a4da876b361b347acf67611a21c8e14be41e6a0 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Tue, 8 Aug 2023 18:20:12 +0200 Subject: [PATCH] add equals/hashCode to KeyValuePair Signed-off-by: Ceki Gulcu --- .../src/main/java/org/slf4j/LoggerFactory.java | 6 ++---- .../main/java/org/slf4j/event/KeyValuePair.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java b/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java index 06828e5e..c204c3e4 100755 --- a/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java +++ b/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java @@ -142,8 +142,6 @@ public final class LoggerFactory { * It is LoggerFactory's responsibility to track version changes and manage * the compatibility list. *

- *

- * It is assumed that all versions in the 1.6 are mutually compatible. */ static private final String[] API_COMPATIBILITY_LIST = new String[] { "2.0" }; @@ -337,7 +335,7 @@ public final class LoggerFactory { } } if (!match) { - Util.report("The requested version " + requested + " by your slf4j binding is not compatible with " + Util.report("The requested version " + requested + " by your slf4j provider is not compatible with " + Arrays.asList(API_COMPATIBILITY_LIST).toString()); Util.report("See " + VERSION_MISMATCH + " for further details."); } @@ -348,7 +346,7 @@ public final class LoggerFactory { // emit compatibility warnings. } catch (Throwable e) { // we should never reach here - Util.report("Unexpected problem occured during version sanity check", e); + Util.report("Unexpected problem occurred during version sanity check", e); } } diff --git a/slf4j-api/src/main/java/org/slf4j/event/KeyValuePair.java b/slf4j-api/src/main/java/org/slf4j/event/KeyValuePair.java index 35bcdd7a..9aebe198 100755 --- a/slf4j-api/src/main/java/org/slf4j/event/KeyValuePair.java +++ b/slf4j-api/src/main/java/org/slf4j/event/KeyValuePair.java @@ -1,5 +1,7 @@ package org.slf4j.event; +import java.util.Objects; + public class KeyValuePair { public final String key; @@ -14,4 +16,17 @@ public class KeyValuePair { public String toString() { return String.valueOf(key) + "=\"" + String.valueOf(value) +"\""; } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + KeyValuePair that = (KeyValuePair) o; + return Objects.equals(key, that.key) && Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash(key, value); + } }