1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.batch.item.file.transform;
18
19 import org.springframework.util.Assert;
20
21
22
23
24
25
26
27
28
29 public class Range {
30
31 public final static int UPPER_BORDER_NOT_DEFINED = Integer.MAX_VALUE;
32
33 final private int min;
34 final private int max;
35
36 public Range(int min) {
37 this(min,UPPER_BORDER_NOT_DEFINED);
38 }
39
40 public Range(int min, int max) {
41 checkMinMaxValues(min, max);
42 this.min = min;
43 this.max = max;
44 }
45
46 public int getMax() {
47 return max;
48 }
49
50 public int getMin() {
51 return min;
52 }
53
54 public boolean hasMaxValue() {
55 return max != UPPER_BORDER_NOT_DEFINED;
56 }
57
58 public String toString() {
59 return hasMaxValue() ? min + "-" + max : String.valueOf(min);
60 }
61
62 private void checkMinMaxValues(int min, int max) {
63 Assert.isTrue(min>0, "Min value must be higher than zero");
64 Assert.isTrue(min<=max, "Min value should be lower or equal to max value");
65 }
66 }