1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.basepom.mojo.propertyhelper.definitions;
16
17 import static com.google.common.base.Preconditions.checkNotNull;
18
19 import java.util.List;
20 import java.util.Objects;
21 import java.util.StringJoiner;
22
23 import com.google.common.annotations.VisibleForTesting;
24 import com.google.common.base.Splitter;
25
26 public class PropertyDefinition {
27
28
29
30
31 String name = null;
32
33
34
35
36 String value = null;
37
38
39
40
41 private List<String> transformers = List.of();
42
43
44 public void setTransformers(String transformers) {
45 this.transformers = Splitter.on(",")
46 .omitEmptyStrings()
47 .trimResults()
48 .splitToList(transformers);
49 }
50
51 @VisibleForTesting
52 PropertyDefinition(final String name, final String value) {
53 this.name = checkNotNull(name, "name is null");
54 this.value = checkNotNull(value, "value is null");
55 }
56
57 public PropertyDefinition() {
58 }
59
60 public void check() {
61 checkNotNull(name, "property name is null");
62 checkNotNull(value, "property value is null");
63 }
64
65 public String getName() {
66 return name;
67 }
68
69 public String getValue() {
70 return value;
71 }
72
73 public List<String> getTransformers() {
74 return transformers;
75 }
76
77 @Override
78 public boolean equals(Object o) {
79 if (this == o) {
80 return true;
81 }
82 if (o == null || getClass() != o.getClass()) {
83 return false;
84 }
85 PropertyDefinition that = (PropertyDefinition) o;
86 return Objects.equals(name, that.name) && Objects.equals(value, that.value) && Objects.equals(transformers,
87 that.transformers);
88 }
89
90 @Override
91 public String toString() {
92 return new StringJoiner(", ", PropertyDefinition.class.getSimpleName() + "[", "]")
93 .add("name='" + name + "'")
94 .add("value='" + value + "'")
95 .add("transformers='" + transformers + "'")
96 .toString();
97 }
98
99 @Override
100 public int hashCode() {
101 return Objects.hash(name, value, transformers);
102 }
103 }
104
105