1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.sw4j.tool.barcode.random.config;
18
19 import com.fasterxml.jackson.annotation.JsonProperty;
20 import java.util.Objects;
21
22
23
24
25
26
27
28
29 public class EncodingConfig {
30
31
32
33
34
35
36 private final String type;
37
38
39
40
41
42
43 private final Integer sepCount;
44
45
46
47
48
49
50 private final Character sepChar;
51
52
53
54
55
56
57
58
59
60 public EncodingConfig(
61 @JsonProperty("type") final String type,
62 @JsonProperty("sep-count") final Integer sepCount,
63 @JsonProperty("sep-char") final Character sepChar) {
64 if (type == null) {
65 throw new IllegalArgumentException(String.format("%s: Missing type", getClass().getSimpleName()));
66 }
67 this.type = type;
68 this.sepCount = sepCount;
69 this.sepChar = sepChar;
70 }
71
72 public String getType() {
73 return type;
74 }
75
76 public Integer getSepCount() {
77 return sepCount;
78 }
79
80 public Character getSepChar() {
81 return sepChar;
82 }
83
84 @Override
85 public int hashCode() {
86 int hash = 3;
87 hash = 19 * hash + Objects.hashCode(this.type);
88 hash = 19 * hash + Objects.hashCode(this.sepCount);
89 hash = 19 * hash + Objects.hashCode(this.sepChar);
90 return hash;
91 }
92
93 @Override
94 public boolean equals(Object obj) {
95 if (this == obj) {
96 return true;
97 }
98 if (obj == null) {
99 return false;
100 }
101 if (getClass() != obj.getClass()) {
102 return false;
103 }
104 final EncodingConfig./../../../org/sw4j/tool/barcode/random/config/EncodingConfig.html#EncodingConfig">EncodingConfig other = (EncodingConfig) obj;
105 if (!Objects.equals(this.type, other.type)) {
106 return false;
107 }
108 if (!Objects.equals(this.sepCount, other.sepCount)) {
109 return false;
110 }
111 return Objects.equals(this.sepChar, other.sepChar);
112 }
113
114 @Override
115 public String toString() {
116 StringBuilder sb = new StringBuilder();
117 sb.append(type);
118 if (sepCount != null) {
119 sb.append("(").append(sepCount).append("|").append(sepChar).append(")");
120 }
121 return sb.toString();
122 }
123
124 public static Builder builder() {
125 return new Builder();
126 }
127
128 public static class Builder {
129
130
131
132
133
134
135 private String type;
136
137
138
139
140
141
142 private Integer sepCount;
143
144
145
146
147
148
149 private Character sepChar;
150
151 public Builder() {
152 }
153
154 public Builder setType(final String type) {
155 this.type = type;
156 return this;
157 }
158
159 public Builder setSepCount(final Integer sepCount) {
160 this.sepCount = sepCount;
161 return this;
162 }
163
164 public Builder setSepChar(final Character sepChar) {
165 this.sepChar = sepChar;
166 return this;
167 }
168
169 public EncodingConfig build() {
170 return new EncodingConfig(type, sepCount, sepChar);
171 }
172
173 }
174
175 }