12
12
import java .util .regex .Pattern ;
13
13
14
14
public final class ComplexValueConverter <T > implements ValueConverter <T > {
15
- private final String rawStringSeparator ;
15
+ private final String stringSeparator ;
16
16
private final List <Entry <T >> entries ;
17
17
private final Supplier <T > constructor ;
18
18
private final String [] sqlColumns ;
19
19
private final String [] sqlColumnDefinitions ;
20
20
21
- private ComplexValueConverter (String rawStringSeparator , List <Entry <T >> entries , Supplier <T > constructor ) {
22
- this .rawStringSeparator = rawStringSeparator ;
21
+ private ComplexValueConverter (String stringSeparator , List <Entry <T >> entries , Supplier <T > constructor ) {
22
+ this .stringSeparator = stringSeparator ;
23
23
this .entries = Collections .unmodifiableList (entries );
24
24
this .constructor = constructor ;
25
25
@@ -41,7 +41,7 @@ public static <T> Builder<T> builder() {
41
41
42
42
@ Override
43
43
public @ NotNull String toRawString (@ NotNull T value ) {
44
- StringJoiner joiner = new StringJoiner (rawStringSeparator );
44
+ StringJoiner joiner = new StringJoiner (stringSeparator );
45
45
for (Entry <T > entry : entries ) {
46
46
String rawString = entry .converter .toRawString (entry .getter .apply (value ));
47
47
joiner .add (rawString );
@@ -51,7 +51,7 @@ public static <T> Builder<T> builder() {
51
51
52
52
@ Override
53
53
public @ Nullable T fromRawString (@ NotNull String value ) {
54
- String [] values = value .split (Pattern .quote (rawStringSeparator ));
54
+ String [] values = value .split (Pattern .quote (stringSeparator ));
55
55
if (values .length != entries .size ()) {
56
56
return null ;
57
57
}
@@ -136,16 +136,16 @@ private Entry(ValueConverter<Object> converter, Function<T, Object> getter, BiFu
136
136
137
137
public static class Builder <T > {
138
138
private final List <Entry <T >> entries ;
139
- private String rawStringSeparator ;
139
+ private String stringSeparator ;
140
140
private Supplier <T > constructor ;
141
141
142
142
private Builder () {
143
143
entries = new ArrayList <>();
144
- rawStringSeparator = "||" ;
144
+ stringSeparator = "||" ;
145
145
}
146
146
147
- public Builder <T > rawStringSeparator (String rawStringSeparator ) {
148
- this .rawStringSeparator = rawStringSeparator ;
147
+ public Builder <T > stringSeparator (String rawStringSeparator ) {
148
+ this .stringSeparator = rawStringSeparator ;
149
149
return this ;
150
150
}
151
151
@@ -155,7 +155,7 @@ public Builder<T> constructor(Supplier<T> constructor) {
155
155
}
156
156
157
157
@ SuppressWarnings ("unchecked" )
158
- public <V > Builder <T > entry (ValueConverter <T > converter , Function <T , V > getter , BiFunction <T , V , T > setter ) {
158
+ public <V > Builder <T > entry (ValueConverter <V > converter , Function <T , V > getter , BiFunction <T , V , T > setter ) {
159
159
ValueConverter <Object > objectConverter = (ValueConverter <Object >) converter ;
160
160
Function <T , Object > objectGetter = (Function <T , Object >) getter ;
161
161
BiFunction <T , Object , T > objectSetter = (BiFunction <T , Object , T >) setter ;
@@ -171,7 +171,7 @@ public ComplexValueConverter<T> build() {
171
171
if (entries .isEmpty ()) {
172
172
throw new IllegalStateException ("Entries are empty" );
173
173
}
174
- return new ComplexValueConverter <>(rawStringSeparator , entries , constructor );
174
+ return new ComplexValueConverter <>(stringSeparator , entries , constructor );
175
175
}
176
176
}
177
177
}
0 commit comments