@@ -13,25 +13,28 @@ public class SampleClause {
13
13
private SampleKeyword keyword ;
14
14
private SampleMethod method ;
15
15
private Number percentageArgument ;
16
+ private String percentageUnit ;
16
17
private Number repeatArgument ;
17
18
// Oracle Specific
18
19
private Number seedArgument ;
19
20
20
21
public SampleClause (String keyword , String method , Number percentageArgument ,
22
+ String percentageUnit ,
21
23
Number repeatArgument , Number seedArgument ) {
22
24
this .keyword = SampleKeyword .from (keyword );
23
25
this .method = method == null || method .length () == 0 ? null : SampleMethod .from (method );
24
26
this .percentageArgument = percentageArgument ;
27
+ this .percentageUnit = percentageUnit ;
25
28
this .repeatArgument = repeatArgument ;
26
29
this .seedArgument = seedArgument ;
27
30
}
28
31
29
32
public SampleClause () {
30
- this (SampleKeyword .TABLESAMPLE .toString (), null , null , null , null );
33
+ this (SampleKeyword .TABLESAMPLE .toString (), null , null , null , null , null );
31
34
}
32
35
33
36
public SampleClause (String keyword ) {
34
- this (keyword , null , null , null , null );
37
+ this (keyword , null , null , null , null , null );
35
38
}
36
39
37
40
public SampleKeyword getKeyword () {
@@ -56,6 +59,15 @@ public Number getRepeatArgument() {
56
59
return repeatArgument ;
57
60
}
58
61
62
+ public String getPercentageUnit () {
63
+ return percentageUnit ;
64
+ }
65
+
66
+ public SampleClause setPercentageUnit (String percentageUnit ) {
67
+ this .percentageUnit = percentageUnit ;
68
+ return this ;
69
+ }
70
+
59
71
public SampleClause setRepeatArgument (Number repeatArgument ) {
60
72
this .repeatArgument = repeatArgument ;
61
73
return this ;
@@ -92,7 +104,8 @@ public StringBuilder appendTo(StringBuilder builder) {
92
104
}
93
105
94
106
if (percentageArgument != null ) {
95
- builder .append (" (" ).append (percentageArgument ).append (")" );
107
+ builder .append (" (" ).append (percentageArgument )
108
+ .append (percentageUnit != null ? " " + percentageUnit : "" ).append (")" );
96
109
}
97
110
98
111
if (repeatArgument != null ) {
@@ -111,18 +124,31 @@ public String toString() {
111
124
}
112
125
113
126
public enum SampleKeyword {
114
- SAMPLE , TABLESAMPLE ;
127
+ SAMPLE ("SAMPLE" ), TABLESAMPLE ("TABLESAMPLE" ), USING_SAMPLE ("USING SAMPLE" );
128
+
129
+ String keyword ;
130
+
131
+ SampleKeyword (String keyword ) {
132
+ this .keyword = keyword ;
133
+ }
115
134
116
135
public static SampleKeyword from (String sampleKeyword ) {
117
- return Enum .valueOf (SampleKeyword .class , sampleKeyword .toUpperCase ());
136
+ return Enum .valueOf (SampleKeyword .class ,
137
+ sampleKeyword .toUpperCase ().replaceAll (" " , "_" ));
138
+ }
139
+
140
+ @ Override
141
+ public String toString () {
142
+ return keyword ;
118
143
}
119
144
}
120
145
121
146
public enum SampleMethod {
122
147
BERNOULLI , SYSTEM , BLOCK ;
123
148
124
149
public static SampleMethod from (String sampleMethod ) {
125
- return Enum .valueOf (SampleMethod .class , sampleMethod .toUpperCase ());
150
+ return Enum .valueOf (SampleMethod .class ,
151
+ sampleMethod .toUpperCase ().replaceAll (" " , "_" ));
126
152
}
127
153
}
128
154
}
0 commit comments