1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.jackson;
18
19 import org.apache.logging.log4j.util.Strings;
20
21 import com.fasterxml.jackson.annotation.JsonCreator;
22 import com.fasterxml.jackson.annotation.JsonProperty;
23 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
24 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
25
26
27
28
29
30
31
32
33
34
35 @JsonPropertyOrder({ "key", "value" })
36 final class MapEntry {
37
38 @JsonProperty
39 @JacksonXmlProperty(isAttribute = true)
40 private String key;
41
42 @JsonProperty
43 @JacksonXmlProperty(isAttribute = true)
44 private String value;
45
46 @JsonCreator
47 public MapEntry(@JsonProperty("key") final String key, @JsonProperty("value") final String value) {
48 this.setKey(key);
49 this.setValue(value);
50 }
51
52 @Override
53 public boolean equals(final Object obj) {
54 if (this == obj) {
55 return true;
56 }
57 if (obj == null) {
58 return false;
59 }
60 if (!(obj instanceof MapEntry)) {
61 return false;
62 }
63 final MapEntry other = (MapEntry) obj;
64 if (this.getKey() == null) {
65 if (other.getKey() != null) {
66 return false;
67 }
68 } else if (!this.getKey().equals(other.getKey())) {
69 return false;
70 }
71 if (this.getValue() == null) {
72 if (other.getValue() != null) {
73 return false;
74 }
75 } else if (!this.getValue().equals(other.getValue())) {
76 return false;
77 }
78 return true;
79 }
80
81 public String getKey() {
82 return this.key;
83 }
84
85 public String getValue() {
86 return this.value;
87 }
88
89 @Override
90 public int hashCode() {
91 final int prime = 31;
92 int result = 1;
93 result = prime * result + ((this.getKey() == null) ? 0 : this.getKey().hashCode());
94 result = prime * result + ((this.getValue() == null) ? 0 : this.getValue().hashCode());
95 return result;
96 }
97
98 public void setKey(final String key) {
99 this.key = key;
100 }
101
102 public void setValue(final String value) {
103 this.value = value;
104 }
105
106 @Override
107 public String toString() {
108 return Strings.EMPTY + this.getKey() + "=" + this.getValue();
109 }
110 }