1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.correction;
|
---|
3 |
|
---|
4 | import java.util.Objects;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Represents a change of a single tag.
|
---|
8 | * Both key and value can be subject of this change.
|
---|
9 | * @since 729
|
---|
10 | */
|
---|
11 | public class TagCorrection implements Correction {
|
---|
12 |
|
---|
13 | /** Old key */
|
---|
14 | public final String oldKey;
|
---|
15 | /** New key */
|
---|
16 | public final String newKey;
|
---|
17 | /** Old value */
|
---|
18 | public final String oldValue;
|
---|
19 | /** New value */
|
---|
20 | public final String newValue;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Constructs a new {@code TagCorrection}.
|
---|
24 | * @param oldKey old key
|
---|
25 | * @param oldValue old value
|
---|
26 | * @param newKey new key
|
---|
27 | * @param newValue new value
|
---|
28 | */
|
---|
29 | public TagCorrection(String oldKey, String oldValue, String newKey, String newValue) {
|
---|
30 | this.oldKey = oldKey;
|
---|
31 | this.oldValue = oldValue;
|
---|
32 | this.newKey = newKey;
|
---|
33 | this.newValue = newValue;
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Determines if the key has changed.
|
---|
38 | * @return {@code true} if the key has changed
|
---|
39 | */
|
---|
40 | public boolean isKeyChanged() {
|
---|
41 | return !newKey.equals(oldKey);
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Determines if the value has changed.
|
---|
46 | * @return {@code true} if the value has changed
|
---|
47 | */
|
---|
48 | public boolean isValueChanged() {
|
---|
49 | return !newValue.equals(oldValue);
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public boolean equals(Object o) {
|
---|
54 | if (this == o) return true;
|
---|
55 | if (o == null || getClass() != o.getClass())
|
---|
56 | return false;
|
---|
57 | TagCorrection that = (TagCorrection) o;
|
---|
58 | return Objects.equals(oldKey, that.oldKey) &&
|
---|
59 | Objects.equals(newKey, that.newKey) &&
|
---|
60 | Objects.equals(oldValue, that.oldValue) &&
|
---|
61 | Objects.equals(newValue, that.newValue);
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Override
|
---|
65 | public int hashCode() {
|
---|
66 | return Objects.hash(oldKey, newKey, oldValue, newValue);
|
---|
67 | }
|
---|
68 | }
|
---|