-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
UsageImp.java
340 lines (332 loc) · 12 KB
/
UsageImp.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/*
* Generated by https://github.com/killbill/api-pojos. Do not edit!
*
* Copyright 2022-2022 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.killbill.billing.catalog.api.boilerplate;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Objects;
import org.killbill.billing.catalog.api.BillingMode;
import org.killbill.billing.catalog.api.BillingPeriod;
import org.killbill.billing.catalog.api.Block;
import org.killbill.billing.catalog.api.InternationalPrice;
import org.killbill.billing.catalog.api.Limit;
import org.killbill.billing.catalog.api.StaticCatalog;
import org.killbill.billing.catalog.api.Tier;
import org.killbill.billing.catalog.api.TierBlockPolicy;
import org.killbill.billing.catalog.api.Usage;
import org.killbill.billing.catalog.api.UsageType;
@JsonDeserialize( builder = UsageImp.Builder.class )
public class UsageImp implements Usage {
protected BillingMode billingMode;
protected BillingPeriod billingPeriod;
protected Block[] blocks;
protected StaticCatalog catalog;
protected InternationalPrice fixedPrice;
protected Limit[] limits;
protected String name;
protected String prettyName;
protected InternationalPrice recurringPrice;
protected TierBlockPolicy tierBlockPolicy;
protected Tier[] tiers;
protected UsageType usageType;
public UsageImp(final UsageImp that) {
this.billingMode = that.billingMode;
this.billingPeriod = that.billingPeriod;
this.blocks = that.blocks;
this.catalog = that.catalog;
this.fixedPrice = that.fixedPrice;
this.limits = that.limits;
this.name = that.name;
this.prettyName = that.prettyName;
this.recurringPrice = that.recurringPrice;
this.tierBlockPolicy = that.tierBlockPolicy;
this.tiers = that.tiers;
this.usageType = that.usageType;
}
protected UsageImp(final UsageImp.Builder<?> builder) {
this.billingMode = builder.billingMode;
this.billingPeriod = builder.billingPeriod;
this.blocks = builder.blocks;
this.catalog = builder.catalog;
this.fixedPrice = builder.fixedPrice;
this.limits = builder.limits;
this.name = builder.name;
this.prettyName = builder.prettyName;
this.recurringPrice = builder.recurringPrice;
this.tierBlockPolicy = builder.tierBlockPolicy;
this.tiers = builder.tiers;
this.usageType = builder.usageType;
}
protected UsageImp() { }
@Override
public BillingMode getBillingMode() {
return this.billingMode;
}
@Override
public BillingPeriod getBillingPeriod() {
return this.billingPeriod;
}
@Override
public Block[] getBlocks() {
return this.blocks;
}
@Override
public StaticCatalog getCatalog() {
return this.catalog;
}
@Override
public InternationalPrice getFixedPrice() {
return this.fixedPrice;
}
@Override
public Limit[] getLimits() {
return this.limits;
}
@Override
public String getName() {
return this.name;
}
@Override
public String getPrettyName() {
return this.prettyName;
}
@Override
public InternationalPrice getRecurringPrice() {
return this.recurringPrice;
}
@Override
public TierBlockPolicy getTierBlockPolicy() {
return this.tierBlockPolicy;
}
@Override
public Tier[] getTiers() {
return this.tiers;
}
@Override
public UsageType getUsageType() {
return this.usageType;
}
@Override
public boolean compliesWithLimits(final String unit, final BigDecimal value) {
throw new UnsupportedOperationException("compliesWithLimits(java.lang.String, java.math.BigDecimal) must be implemented.");
}
@Override
public boolean equals(final Object o) {
if ( this == o ) {
return true;
}
if ( ( o == null ) || ( this.getClass() != o.getClass() ) ) {
return false;
}
final UsageImp that = (UsageImp) o;
if( !Objects.equals(this.billingMode, that.billingMode) ) {
return false;
}
if( !Objects.equals(this.billingPeriod, that.billingPeriod) ) {
return false;
}
if( !Arrays.deepEquals(this.blocks, that.blocks) ) {
return false;
}
if( !Objects.equals(this.catalog, that.catalog) ) {
return false;
}
if( !Objects.equals(this.fixedPrice, that.fixedPrice) ) {
return false;
}
if( !Arrays.deepEquals(this.limits, that.limits) ) {
return false;
}
if( !Objects.equals(this.name, that.name) ) {
return false;
}
if( !Objects.equals(this.prettyName, that.prettyName) ) {
return false;
}
if( !Objects.equals(this.recurringPrice, that.recurringPrice) ) {
return false;
}
if( !Objects.equals(this.tierBlockPolicy, that.tierBlockPolicy) ) {
return false;
}
if( !Arrays.deepEquals(this.tiers, that.tiers) ) {
return false;
}
if( !Objects.equals(this.usageType, that.usageType) ) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = 1;
result = ( 31 * result ) + Objects.hashCode(this.billingMode);
result = ( 31 * result ) + Objects.hashCode(this.billingPeriod);
result = ( 31 * result ) + Arrays.deepHashCode(this.blocks);
result = ( 31 * result ) + Objects.hashCode(this.catalog);
result = ( 31 * result ) + Objects.hashCode(this.fixedPrice);
result = ( 31 * result ) + Arrays.deepHashCode(this.limits);
result = ( 31 * result ) + Objects.hashCode(this.name);
result = ( 31 * result ) + Objects.hashCode(this.prettyName);
result = ( 31 * result ) + Objects.hashCode(this.recurringPrice);
result = ( 31 * result ) + Objects.hashCode(this.tierBlockPolicy);
result = ( 31 * result ) + Arrays.deepHashCode(this.tiers);
result = ( 31 * result ) + Objects.hashCode(this.usageType);
return result;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer(this.getClass().getSimpleName());
sb.append("{");
sb.append("billingMode=").append(this.billingMode);
sb.append(", ");
sb.append("billingPeriod=").append(this.billingPeriod);
sb.append(", ");
sb.append("blocks=").append(Arrays.toString(this.blocks));
sb.append(", ");
sb.append("catalog=").append(this.catalog);
sb.append(", ");
sb.append("fixedPrice=").append(this.fixedPrice);
sb.append(", ");
sb.append("limits=").append(Arrays.toString(this.limits));
sb.append(", ");
sb.append("name=");
if( this.name == null ) {
sb.append(this.name);
}else{
sb.append("'").append(this.name).append("'");
}
sb.append(", ");
sb.append("prettyName=");
if( this.prettyName == null ) {
sb.append(this.prettyName);
}else{
sb.append("'").append(this.prettyName).append("'");
}
sb.append(", ");
sb.append("recurringPrice=").append(this.recurringPrice);
sb.append(", ");
sb.append("tierBlockPolicy=").append(this.tierBlockPolicy);
sb.append(", ");
sb.append("tiers=").append(Arrays.toString(this.tiers));
sb.append(", ");
sb.append("usageType=").append(this.usageType);
sb.append("}");
return sb.toString();
}
@SuppressWarnings("unchecked")
public static class Builder<T extends UsageImp.Builder<T>> {
protected BillingMode billingMode;
protected BillingPeriod billingPeriod;
protected Block[] blocks;
protected StaticCatalog catalog;
protected InternationalPrice fixedPrice;
protected Limit[] limits;
protected String name;
protected String prettyName;
protected InternationalPrice recurringPrice;
protected TierBlockPolicy tierBlockPolicy;
protected Tier[] tiers;
protected UsageType usageType;
public Builder() { }
public Builder(final Builder that) {
this.billingMode = that.billingMode;
this.billingPeriod = that.billingPeriod;
this.blocks = that.blocks;
this.catalog = that.catalog;
this.fixedPrice = that.fixedPrice;
this.limits = that.limits;
this.name = that.name;
this.prettyName = that.prettyName;
this.recurringPrice = that.recurringPrice;
this.tierBlockPolicy = that.tierBlockPolicy;
this.tiers = that.tiers;
this.usageType = that.usageType;
}
public T withBillingMode(final BillingMode billingMode) {
this.billingMode = billingMode;
return (T) this;
}
public T withBillingPeriod(final BillingPeriod billingPeriod) {
this.billingPeriod = billingPeriod;
return (T) this;
}
public T withBlocks(final Block[] blocks) {
this.blocks = blocks;
return (T) this;
}
public T withCatalog(final StaticCatalog catalog) {
this.catalog = catalog;
return (T) this;
}
public T withFixedPrice(final InternationalPrice fixedPrice) {
this.fixedPrice = fixedPrice;
return (T) this;
}
public T withLimits(final Limit[] limits) {
this.limits = limits;
return (T) this;
}
public T withName(final String name) {
this.name = name;
return (T) this;
}
public T withPrettyName(final String prettyName) {
this.prettyName = prettyName;
return (T) this;
}
public T withRecurringPrice(final InternationalPrice recurringPrice) {
this.recurringPrice = recurringPrice;
return (T) this;
}
public T withTierBlockPolicy(final TierBlockPolicy tierBlockPolicy) {
this.tierBlockPolicy = tierBlockPolicy;
return (T) this;
}
public T withTiers(final Tier[] tiers) {
this.tiers = tiers;
return (T) this;
}
public T withUsageType(final UsageType usageType) {
this.usageType = usageType;
return (T) this;
}
public T source(final Usage that) {
this.billingMode = that.getBillingMode();
this.billingPeriod = that.getBillingPeriod();
this.blocks = that.getBlocks();
this.catalog = that.getCatalog();
this.fixedPrice = that.getFixedPrice();
this.limits = that.getLimits();
this.name = that.getName();
this.prettyName = that.getPrettyName();
this.recurringPrice = that.getRecurringPrice();
this.tierBlockPolicy = that.getTierBlockPolicy();
this.tiers = that.getTiers();
this.usageType = that.getUsageType();
return (T) this;
}
protected Builder validate() {
return this;
}
public UsageImp build() {
return new UsageImp(this.validate());
}
}
}