Skip to content

Commit 84c4fbe

Browse files
committed
#57 - hacking - always nice when code compiles.
1 parent 977cc53 commit 84c4fbe

File tree

1 file changed

+20
-19
lines changed
  • src/main/java/org/springframework/data/r2dbc/function

1 file changed

+20
-19
lines changed

src/main/java/org/springframework/data/r2dbc/function/Bindings.java

+20-19
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.data.r2dbc.function;
1717

1818
import io.r2dbc.spi.Statement;
19+
import lombok.RequiredArgsConstructor;
1920
import lombok.Value;
2021

2122
import java.util.List;
@@ -33,23 +34,22 @@ public Bindings(List<SingleBinding> bindings) {
3334
this.bindings = bindings;
3435
}
3536

37+
@RequiredArgsConstructor
38+
public static abstract class SingleBinding<T> {
3639

37-
@Value
38-
public static abstract class SingleBinding<T> {
39-
40-
T identifier;
41-
SettableValue value;
40+
final T identifier;
41+
final SettableValue value;
4242

4343
public abstract void bindTo(Statement statement);
4444

45-
public abstract boolean isIndexed();
45+
public abstract boolean isIndexed();
4646

4747
public final boolean isNamed() {
4848
return !isIndexed();
4949
}
5050
}
5151

52-
public static class NamedSingleBinding<T> extends SingleBinding<T>{
52+
public static class NamedSingleBinding<T> extends SingleBinding<T> {
5353

5454
public NamedSingleBinding(T identifier, SettableValue value) {
5555
super(identifier, value);
@@ -58,11 +58,11 @@ public NamedSingleBinding(T identifier, SettableValue value) {
5858
@Override
5959
public void bindTo(Statement statement) {
6060

61-
if (getValue().isEmpty()) {
62-
statement.bindNull(getIdentifier(), getValue().getType());
61+
if (value.isEmpty()) {
62+
statement.bindNull(identifier, value.getType());
6363
}
6464

65-
statement.bind(getIdentifier(), getValue());
65+
statement.bind(identifier, value);
6666
}
6767

6868
@Override
@@ -71,7 +71,7 @@ public boolean isIndexed() {
7171
}
7272
}
7373

74-
public static class IndexedSingleBinding extends SingleBinding<Integer>{
74+
public static class IndexedSingleBinding extends SingleBinding<Integer> {
7575

7676
public IndexedSingleBinding(Integer identifier, SettableValue value) {
7777
super(identifier, value);
@@ -80,23 +80,24 @@ public IndexedSingleBinding(Integer identifier, SettableValue value) {
8080
@Override
8181
public void bindTo(Statement statement) {
8282

83-
if (getValue().isEmpty()) {
84-
statement.bindNull((int)getIdentifier(), getValue().getType());
83+
if (value.isEmpty()) {
84+
statement.bindNull((int) identifier, value.getType());
8585
}
8686

87-
statement.bind((int)getIdentifier(), getValue());
87+
statement.bind((int) identifier, value);
8888
}
89+
8990
@Override
9091
public boolean isIndexed() {
9192
return true;
9293
}
9394
}
9495

95-
public static class NamedExpandedSingleBinding<T> extends SingleBinding<T>{
96+
public static class NamedExpandedSingleBinding extends SingleBinding<String> {
9697

9798
private final BindableOperation operation;
9899

99-
public NamedExpandedSingleBinding(T identifier, SettableValue value, BindableOperation operation) {
100+
public NamedExpandedSingleBinding(String identifier, SettableValue value, BindableOperation operation) {
100101

101102
super(identifier, value);
102103

@@ -106,10 +107,10 @@ public NamedExpandedSingleBinding(T identifier, SettableValue value, BindableOpe
106107
@Override
107108
public void bindTo(Statement statement) {
108109

109-
if (getValue() != null) {
110-
operation.bind(statement,getIdentifier(), getValue());
110+
if (value != null) {
111+
operation.bind(statement, identifier, value);
111112
} else {
112-
operation.bindNull(statement, getIdentifier(), getValue().getType());
113+
operation.bindNull(statement, identifier, value.getType());
113114
}
114115
}
115116

0 commit comments

Comments
 (0)