Skip to content

Commit

Permalink
add equals/hashCode to KeyValuePair
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Aug 8, 2023
1 parent 0769bc8 commit 7a4da87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions slf4j-api/src/main/java/org/slf4j/LoggerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ private static void safelyInstantiate(List<SLF4JServiceProvider> providerList, I
* It is LoggerFactory's responsibility to track version changes and manage
* the compatibility list.
* <p>
* <p>
* It is assumed that all versions in the 1.6 are mutually compatible.
*/
static private final String[] API_COMPATIBILITY_LIST = new String[] { "2.0" };

Expand Down Expand Up @@ -337,7 +335,7 @@ private final static void versionSanityCheck() {
}
}
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.");
}
Expand All @@ -348,7 +346,7 @@ private final static void versionSanityCheck() {
// 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);
}
}

Expand Down
15 changes: 15 additions & 0 deletions slf4j-api/src/main/java/org/slf4j/event/KeyValuePair.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.slf4j.event;

import java.util.Objects;

public class KeyValuePair {

public final String key;
Expand All @@ -14,4 +16,17 @@ public KeyValuePair(String key, Object value) {
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);
}
}

0 comments on commit 7a4da87

Please sign in to comment.