Skip to content

Commit 20eb2c1

Browse files
committed
#2 - Resolve package cycle between r2dbc.function and r2dbc.function.convert.
1 parent f223475 commit 20eb2c1

File tree

6 files changed

+93
-54
lines changed

6 files changed

+93
-54
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
import org.springframework.data.domain.Sort.NullHandling;
5353
import org.springframework.data.domain.Sort.Order;
5454
import org.springframework.data.r2dbc.UncategorizedR2dbcException;
55-
import org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy.SettableValue;
5655
import org.springframework.data.r2dbc.function.connectionfactory.ConnectionProxy;
5756
import org.springframework.data.r2dbc.function.convert.ColumnMapRowMapper;
57+
import org.springframework.data.r2dbc.function.convert.SettableValue;
5858
import org.springframework.data.r2dbc.support.R2dbcExceptionTranslator;
5959
import org.springframework.jdbc.core.SqlProvider;
6060
import org.springframework.lang.Nullable;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.data.domain.Sort.Order;
2929
import org.springframework.data.mapping.PersistentPropertyAccessor;
3030
import org.springframework.data.r2dbc.function.convert.EntityRowMapper;
31+
import org.springframework.data.r2dbc.function.convert.SettableValue;
3132
import org.springframework.data.relational.core.conversion.BasicRelationalConverter;
3233
import org.springframework.data.relational.core.conversion.RelationalConverter;
3334
import org.springframework.data.relational.core.mapping.RelationalMappingContext;

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

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,72 +22,40 @@
2222
import java.util.function.BiFunction;
2323

2424
import org.springframework.data.domain.Sort;
25-
import org.springframework.lang.Nullable;
25+
import org.springframework.data.r2dbc.function.convert.SettableValue;
2626

2727
/**
2828
* @author Mark Paluch
2929
*/
3030
public interface ReactiveDataAccessStrategy {
3131

32+
/**
33+
* @param typeToRead
34+
* @return all field names for a specific type.
35+
*/
3236
List<String> getAllFields(Class<?> typeToRead);
3337

38+
/**
39+
* @param object
40+
* @return {@link SettableValue} that represent an {@code INSERT} of {@code object}.
41+
*/
3442
List<SettableValue> getInsert(Object object);
3543

44+
/**
45+
* Map the {@link Sort} object to apply field name mapping using {@link Class the type to read}.
46+
*
47+
* @param typeToRead
48+
* @param sort
49+
* @return
50+
*/
3651
Sort getMappedSort(Class<?> typeToRead, Sort sort);
3752

3853
// TODO: Broaden T to Mono<T>/Flux<T> for reactive relational data access?
3954
<T> BiFunction<Row, RowMetadata, T> getRowMapper(Class<T> typeToRead);
4055

41-
String getTableName(Class<?> type);
42-
4356
/**
44-
* A database value that can be set in a statement.
57+
* @param type
58+
* @return the table name for the {@link Class entity type}.
4559
*/
46-
class SettableValue {
47-
48-
private final Object identifier;
49-
private final @Nullable Object value;
50-
private final Class<?> type;
51-
52-
/**
53-
* Create a {@link SettableValue} using an integer index.
54-
*
55-
* @param index
56-
* @param value
57-
* @param type
58-
*/
59-
public SettableValue(int index, @Nullable Object value, Class<?> type) {
60-
61-
this.identifier = index;
62-
this.value = value;
63-
this.type = type;
64-
}
65-
66-
/**
67-
* Create a {@link SettableValue} using a {@link String} identifier.
68-
*
69-
* @param identifier
70-
* @param value
71-
* @param type
72-
*/
73-
public SettableValue(String identifier, @Nullable Object value, Class<?> type) {
74-
75-
this.identifier = identifier;
76-
this.value = value;
77-
this.type = type;
78-
}
79-
80-
public Object getIdentifier() {
81-
return identifier;
82-
}
83-
84-
@Nullable
85-
public Object getValue() {
86-
return value;
87-
}
88-
89-
public Class<?> getType() {
90-
return type;
91-
}
92-
}
60+
String getTableName(Class<?> type);
9361
}

src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.core.convert.ConversionService;
2727
import org.springframework.data.mapping.PersistentPropertyAccessor;
2828
import org.springframework.data.mapping.context.MappingContext;
29-
import org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy.SettableValue;
3029
import org.springframework.data.relational.core.conversion.RelationalConverter;
3130
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
3231
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.r2dbc.function.convert;
17+
18+
import org.springframework.lang.Nullable;
19+
20+
/**
21+
* A database value that can be set in a statement.
22+
*
23+
* @author Mark Paluch
24+
*/
25+
public class SettableValue {
26+
27+
private final Object identifier;
28+
private final @Nullable Object value;
29+
private final Class<?> type;
30+
31+
/**
32+
* Create a {@link SettableValue} using an integer index.
33+
*
34+
* @param index
35+
* @param value
36+
* @param type
37+
*/
38+
public SettableValue(int index, @Nullable Object value, Class<?> type) {
39+
40+
this.identifier = index;
41+
this.value = value;
42+
this.type = type;
43+
}
44+
45+
/**
46+
* Create a {@link SettableValue} using a {@link String} identifier.
47+
*
48+
* @param identifier
49+
* @param value
50+
* @param type
51+
*/
52+
public SettableValue(String identifier, @Nullable Object value, Class<?> type) {
53+
54+
this.identifier = identifier;
55+
this.value = value;
56+
this.type = type;
57+
}
58+
59+
public Object getIdentifier() {
60+
return identifier;
61+
}
62+
63+
@Nullable
64+
public Object getValue() {
65+
return value;
66+
}
67+
68+
public Class<?> getType() {
69+
return type;
70+
}
71+
}

src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.springframework.data.r2dbc.function.DatabaseClient.BindSpec;
3131
import org.springframework.data.r2dbc.function.DatabaseClient.GenericExecuteSpec;
3232
import org.springframework.data.r2dbc.function.FetchSpec;
33-
import org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy.SettableValue;
3433
import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter;
34+
import org.springframework.data.r2dbc.function.convert.SettableValue;
3535
import org.springframework.data.relational.repository.query.RelationalEntityInformation;
3636
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
3737
import org.springframework.util.Assert;

0 commit comments

Comments
 (0)