001package org.slf4j.event; 002 003import java.util.Objects; 004 005/** 006 * Instances of this class store the key value pair passed to a {@link org.slf4j.Logger logger} via 007 * the {@link org.slf4j.spi.LoggingEventBuilder#addKeyValue(String, Object)} method of the fluent API. 008 * 009 * @since 2.0.0 010 */ 011public class KeyValuePair { 012 013 public final String key; 014 public final Object value; 015 016 public KeyValuePair(String key, Object value) { 017 this.key = key; 018 this.value = value; 019 } 020 021 @Override 022 public String toString() { 023 return String.valueOf(key) + "=\"" + String.valueOf(value) +"\""; 024 } 025 026 @Override 027 public boolean equals(Object o) { 028 if(this == o) return true; 029 if(o == null || getClass() != o.getClass()) return false; 030 KeyValuePair that = (KeyValuePair) o; 031 return Objects.equals(key, that.key) && Objects.equals(value, that.value); 032 } 033 034 @Override 035 public int hashCode() { 036 return Objects.hash(key, value); 037 } 038}