Skip to content

Commit c412aad

Browse files
committed
DATAJDBC-235 - Polishing.
Corrected nullability annotations. Minor improvements in Javadoc. Added @author tags. Removed unused imports.
1 parent 2c5489b commit c412aad

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.apache.ibatis.session.SqlSession;
2424
import org.mybatis.spring.SqlSessionTemplate;
25-
import org.springframework.data.convert.EntityInstantiators;
2625
import org.springframework.data.jdbc.core.CascadingDataAccessStrategy;
2726
import org.springframework.data.jdbc.core.DataAccessStrategy;
2827
import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
@@ -60,10 +59,8 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
6059
* uses a {@link DefaultDataAccessStrategy}
6160
*/
6261
public static DataAccessStrategy createCombinedAccessStrategy(RelationalMappingContext context,
63-
RelationalConverter converter,
64-
NamedParameterJdbcOperations operations, SqlSession sqlSession) {
65-
return createCombinedAccessStrategy(context, converter, operations, sqlSession,
66-
NamespaceStrategy.DEFAULT_INSTANCE);
62+
RelationalConverter converter, NamedParameterJdbcOperations operations, SqlSession sqlSession) {
63+
return createCombinedAccessStrategy(context, converter, operations, sqlSession, NamespaceStrategy.DEFAULT_INSTANCE);
6764
}
6865

6966
/**
@@ -105,7 +102,7 @@ public static DataAccessStrategy createCombinedAccessStrategy(RelationalMappingC
105102
* transaction. Note that the resulting {@link DataAccessStrategy} only handles MyBatis. It does not include the
106103
* functionality of the {@link org.springframework.data.jdbc.core.DefaultDataAccessStrategy} which one normally still
107104
* wants. Use
108-
* {@link #createCombinedAccessStrategy(RelationalMappingContext, EntityInstantiators, NamedParameterJdbcOperations, SqlSession, NamespaceStrategy)}
105+
* {@link #createCombinedAccessStrategy(RelationalMappingContext, RelationalConverter, NamedParameterJdbcOperations, SqlSession, NamespaceStrategy)}
109106
* to create such a {@link DataAccessStrategy}.
110107
*
111108
* @param sqlSession Must be non {@literal null}.

src/main/java/org/springframework/data/jdbc/repository/config/JdbcConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ RelationalConverter relationalConverter(RelationalMappingContext mappingContext,
5757

5858
/**
5959
* Register custom {@link Converter}s in a {@link CustomConversions} object if required. These
60-
* {@link CustomConversions} will be registered with the {@link #jdbcMappingContext()}. Returns an empty
60+
* {@link CustomConversions} will be registered with the
61+
* {@link #relationalConverter(RelationalMappingContext, CustomConversions)}. Returns an empty
6162
* {@link JdbcCustomConversions} instance by default.
6263
*
6364
* @return must not be {@literal null}.

src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* @author Jens Schauder
4040
* @author Kazuki Shimizu
4141
* @author Oliver Gierke
42+
* @author Mark Paluch
4243
* @since 1.0
4344
*/
4445
class JdbcQueryLookupStrategy implements QueryLookupStrategy {

src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBean.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* @author Greg Turnquist
4141
* @author Christoph Strobl
4242
* @author Oliver Gierke
43+
* @author Mark Paluch
4344
* @since 1.0
4445
*/
4546
public class JdbcRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable> //

src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ public Object writeValue(@Nullable Object value, TypeInformation<?> type) {
192192
* Checks whether we have a custom conversion registered for the given value into an arbitrary simple JDBC type.
193193
* Returns the converted value if so. If not, we perform special enum handling or simply return the value as is.
194194
*
195-
* @param value
196-
* @return
195+
* @param value to be converted. Must not be {@code null}.
196+
* @return the converted value if a conversion applies or the original value. Might return {@code null}.
197197
*/
198+
@Nullable
198199
private Object getPotentiallyConvertedSimpleWrite(Object value) {
199200

200201
Optional<Class<?>> customTarget = conversions.getCustomWriteTarget(value.getClass());
@@ -210,9 +211,9 @@ private Object getPotentiallyConvertedSimpleWrite(Object value) {
210211
* Checks whether we have a custom conversion for the given simple object. Converts the given value if so, applies
211212
* {@link Enum} handling or returns the value as is.
212213
*
213-
* @param value
214-
* @param target must not be {@literal null}.
215-
* @return
214+
* @param value to be converted. May be {@code null}..
215+
* @param target May be {@code null}..
216+
* @return the converted value if a conversion applies or the original value. Might return {@code null}.
216217
*/
217218
@Nullable
218219
@SuppressWarnings({ "rawtypes", "unchecked" })

src/main/java/org/springframework/data/relational/core/conversion/RelationalConverter.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* vice versa.
3434
*
3535
* @author Mark Paluch
36+
* @author Jens Schauder
3637
*/
3738
public interface RelationalConverter {
3839

@@ -54,39 +55,39 @@ public interface RelationalConverter {
5455
* Create a new instance of {@link PersistentEntity} given {@link ParameterValueProvider} to obtain constructor
5556
* properties.
5657
*
57-
* @param entity
58-
* @param parameterValueProvider
59-
* @param <T>
60-
* @return
58+
* @param entity the kind of entity to create. Must not be {@code null}.
59+
* @param parameterValueProvider a function that provides the value to pass to a constructor, given a {@link Parameter}. Must not be {@code null}.
60+
* @param <T> the type of entity to create.
61+
* @return the instantiated entity. Guaranteed to be not {@code null}.
6162
*/
6263
<T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity,
6364
Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider);
6465

6566
/**
6667
* Return a {@link PersistentPropertyAccessor} to access property values of the {@code instance}.
6768
*
68-
* @param persistentEntity
69-
* @param instance
70-
* @return
69+
* @param persistentEntity the kind of entity to operate on. Must not be {@code null}.
70+
* @param instance the instance to operate on. Must not be {@code null}.
71+
* @return Guaranteed to be not {@code null}.
7172
*/
7273
<T> PersistentPropertyAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance);
7374

7475
/**
7576
* Read a relational value into the desired {@link TypeInformation destination type}.
7677
*
77-
* @param value
78-
* @param type
79-
* @return
78+
* @param value a value as it is returned by the driver accessing the persistence store. May be {@code null}.
79+
* @param type {@link TypeInformation} into which the value is to be converted. Must not be {@code null}.
80+
* @return The converted value. May be {@code null}.
8081
*/
8182
@Nullable
8283
Object readValue(@Nullable Object value, TypeInformation<?> type);
8384

8485
/**
8586
* Write a property value into a relational type that can be stored natively.
8687
*
87-
* @param value
88-
* @param type
89-
* @return
88+
* @param value a value as it is used in the object model. May be {@code null}.
89+
* @param type {@link TypeInformation} into which the value is to be converted. Must not be {@code null}.
90+
* @return The converted value. May be {@code null}.
9091
*/
9192
@Nullable
9293
Object writeValue(@Nullable Object value, TypeInformation<?> type);

src/main/java/org/springframework/data/relational/core/mapping/RelationalMappingContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public RelationalMappingContext() {
5555
* Creates a new {@link RelationalMappingContext} using the given {@link NamingStrategy}.
5656
*
5757
* @param namingStrategy must not be {@literal null}.
58-
* @param customizer must not be {@literal null}.
5958
*/
6059
public RelationalMappingContext(NamingStrategy namingStrategy) {
6160

0 commit comments

Comments
 (0)