16
16
package org .springframework .data .r2dbc .function ;
17
17
18
18
import io .r2dbc .spi .Statement ;
19
+ import lombok .RequiredArgsConstructor ;
19
20
import lombok .Value ;
20
21
21
22
import java .util .List ;
@@ -33,23 +34,22 @@ public Bindings(List<SingleBinding> bindings) {
33
34
this .bindings = bindings ;
34
35
}
35
36
37
+ @ RequiredArgsConstructor
38
+ public static abstract class SingleBinding <T > {
36
39
37
- @ Value
38
- public static abstract class SingleBinding <T > {
39
-
40
- T identifier ;
41
- SettableValue value ;
40
+ final T identifier ;
41
+ final SettableValue value ;
42
42
43
43
public abstract void bindTo (Statement statement );
44
44
45
- public abstract boolean isIndexed ();
45
+ public abstract boolean isIndexed ();
46
46
47
47
public final boolean isNamed () {
48
48
return !isIndexed ();
49
49
}
50
50
}
51
51
52
- public static class NamedSingleBinding <T > extends SingleBinding <T >{
52
+ public static class NamedSingleBinding <T > extends SingleBinding <T > {
53
53
54
54
public NamedSingleBinding (T identifier , SettableValue value ) {
55
55
super (identifier , value );
@@ -58,11 +58,11 @@ public NamedSingleBinding(T identifier, SettableValue value) {
58
58
@ Override
59
59
public void bindTo (Statement statement ) {
60
60
61
- if (getValue () .isEmpty ()) {
62
- statement .bindNull (getIdentifier (), getValue () .getType ());
61
+ if (value .isEmpty ()) {
62
+ statement .bindNull (identifier , value .getType ());
63
63
}
64
64
65
- statement .bind (getIdentifier (), getValue () );
65
+ statement .bind (identifier , value );
66
66
}
67
67
68
68
@ Override
@@ -71,7 +71,7 @@ public boolean isIndexed() {
71
71
}
72
72
}
73
73
74
- public static class IndexedSingleBinding extends SingleBinding <Integer >{
74
+ public static class IndexedSingleBinding extends SingleBinding <Integer > {
75
75
76
76
public IndexedSingleBinding (Integer identifier , SettableValue value ) {
77
77
super (identifier , value );
@@ -80,23 +80,24 @@ public IndexedSingleBinding(Integer identifier, SettableValue value) {
80
80
@ Override
81
81
public void bindTo (Statement statement ) {
82
82
83
- if (getValue () .isEmpty ()) {
84
- statement .bindNull ((int )getIdentifier (), getValue () .getType ());
83
+ if (value .isEmpty ()) {
84
+ statement .bindNull ((int ) identifier , value .getType ());
85
85
}
86
86
87
- statement .bind ((int )getIdentifier (), getValue () );
87
+ statement .bind ((int ) identifier , value );
88
88
}
89
+
89
90
@ Override
90
91
public boolean isIndexed () {
91
92
return true ;
92
93
}
93
94
}
94
95
95
- public static class NamedExpandedSingleBinding < T > extends SingleBinding <T > {
96
+ public static class NamedExpandedSingleBinding extends SingleBinding <String > {
96
97
97
98
private final BindableOperation operation ;
98
99
99
- public NamedExpandedSingleBinding (T identifier , SettableValue value , BindableOperation operation ) {
100
+ public NamedExpandedSingleBinding (String identifier , SettableValue value , BindableOperation operation ) {
100
101
101
102
super (identifier , value );
102
103
@@ -106,10 +107,10 @@ public NamedExpandedSingleBinding(T identifier, SettableValue value, BindableOpe
106
107
@ Override
107
108
public void bindTo (Statement statement ) {
108
109
109
- if (getValue () != null ) {
110
- operation .bind (statement ,getIdentifier (), getValue () );
110
+ if (value != null ) {
111
+ operation .bind (statement , identifier , value );
111
112
} else {
112
- operation .bindNull (statement , getIdentifier (), getValue () .getType ());
113
+ operation .bindNull (statement , identifier , value .getType ());
113
114
}
114
115
}
115
116
0 commit comments