DATAJDBC-235 - Polishing.

Corrected nullability annotations.
Minor improvements in Javadoc.
Added @author tags.
Removed unused imports.
This commit is contained in:
Jens Schauder
2018-07-18 11:03:15 +02:00
parent 2c5489b070
commit c412aad6b8
7 changed files with 27 additions and 26 deletions

View File

@@ -22,7 +22,6 @@ import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.data.convert.EntityInstantiators;
import org.springframework.data.jdbc.core.CascadingDataAccessStrategy;
import org.springframework.data.jdbc.core.DataAccessStrategy;
import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
@@ -60,10 +59,8 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
* uses a {@link DefaultDataAccessStrategy}
*/
public static DataAccessStrategy createCombinedAccessStrategy(RelationalMappingContext context,
RelationalConverter converter,
NamedParameterJdbcOperations operations, SqlSession sqlSession) {
return createCombinedAccessStrategy(context, converter, operations, sqlSession,
NamespaceStrategy.DEFAULT_INSTANCE);
RelationalConverter converter, NamedParameterJdbcOperations operations, SqlSession sqlSession) {
return createCombinedAccessStrategy(context, converter, operations, sqlSession, NamespaceStrategy.DEFAULT_INSTANCE);
}
/**
@@ -105,7 +102,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
* transaction. Note that the resulting {@link DataAccessStrategy} only handles MyBatis. It does not include the
* functionality of the {@link org.springframework.data.jdbc.core.DefaultDataAccessStrategy} which one normally still
* wants. Use
* {@link #createCombinedAccessStrategy(RelationalMappingContext, EntityInstantiators, NamedParameterJdbcOperations, SqlSession, NamespaceStrategy)}
* {@link #createCombinedAccessStrategy(RelationalMappingContext, RelationalConverter, NamedParameterJdbcOperations, SqlSession, NamespaceStrategy)}
* to create such a {@link DataAccessStrategy}.
*
* @param sqlSession Must be non {@literal null}.

View File

@@ -57,7 +57,8 @@ public class JdbcConfiguration {
/**
* Register custom {@link Converter}s in a {@link CustomConversions} object if required. These
* {@link CustomConversions} will be registered with the {@link #jdbcMappingContext()}. Returns an empty
* {@link CustomConversions} will be registered with the
* {@link #relationalConverter(RelationalMappingContext, CustomConversions)}. Returns an empty
* {@link JdbcCustomConversions} instance by default.
*
* @return must not be {@literal null}.

View File

@@ -39,6 +39,7 @@ import org.springframework.util.Assert;
* @author Jens Schauder
* @author Kazuki Shimizu
* @author Oliver Gierke
* @author Mark Paluch
* @since 1.0
*/
class JdbcQueryLookupStrategy implements QueryLookupStrategy {

View File

@@ -40,6 +40,7 @@ import org.springframework.util.Assert;
* @author Greg Turnquist
* @author Christoph Strobl
* @author Oliver Gierke
* @author Mark Paluch
* @since 1.0
*/
public class JdbcRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable> //

View File

@@ -192,9 +192,10 @@ public class BasicRelationalConverter implements RelationalConverter {
* Checks whether we have a custom conversion registered for the given value into an arbitrary simple JDBC type.
* Returns the converted value if so. If not, we perform special enum handling or simply return the value as is.
*
* @param value
* @return
* @param value to be converted. Must not be {@code null}.
* @return the converted value if a conversion applies or the original value. Might return {@code null}.
*/
@Nullable
private Object getPotentiallyConvertedSimpleWrite(Object value) {
Optional<Class<?>> customTarget = conversions.getCustomWriteTarget(value.getClass());
@@ -210,9 +211,9 @@ public class BasicRelationalConverter implements RelationalConverter {
* Checks whether we have a custom conversion for the given simple object. Converts the given value if so, applies
* {@link Enum} handling or returns the value as is.
*
* @param value
* @param target must not be {@literal null}.
* @return
* @param value to be converted. May be {@code null}..
* @param target May be {@code null}..
* @return the converted value if a conversion applies or the original value. Might return {@code null}.
*/
@Nullable
@SuppressWarnings({ "rawtypes", "unchecked" })

View File

@@ -33,6 +33,7 @@ import org.springframework.lang.Nullable;
* vice versa.
*
* @author Mark Paluch
* @author Jens Schauder
*/
public interface RelationalConverter {
@@ -54,10 +55,10 @@ public interface RelationalConverter {
* Create a new instance of {@link PersistentEntity} given {@link ParameterValueProvider} to obtain constructor
* properties.
*
* @param entity
* @param parameterValueProvider
* @param <T>
* @return
* @param entity the kind of entity to create. Must not be {@code null}.
* @param parameterValueProvider a function that provides the value to pass to a constructor, given a {@link Parameter}. Must not be {@code null}.
* @param <T> the type of entity to create.
* @return the instantiated entity. Guaranteed to be not {@code null}.
*/
<T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity,
Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider);
@@ -65,18 +66,18 @@ public interface RelationalConverter {
/**
* Return a {@link PersistentPropertyAccessor} to access property values of the {@code instance}.
*
* @param persistentEntity
* @param instance
* @return
* @param persistentEntity the kind of entity to operate on. Must not be {@code null}.
* @param instance the instance to operate on. Must not be {@code null}.
* @return Guaranteed to be not {@code null}.
*/
<T> PersistentPropertyAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance);
/**
* Read a relational value into the desired {@link TypeInformation destination type}.
*
* @param value
* @param type
* @return
* @param value a value as it is returned by the driver accessing the persistence store. May be {@code null}.
* @param type {@link TypeInformation} into which the value is to be converted. Must not be {@code null}.
* @return The converted value. May be {@code null}.
*/
@Nullable
Object readValue(@Nullable Object value, TypeInformation<?> type);
@@ -84,9 +85,9 @@ public interface RelationalConverter {
/**
* Write a property value into a relational type that can be stored natively.
*
* @param value
* @param type
* @return
* @param value a value as it is used in the object model. May be {@code null}.
* @param type {@link TypeInformation} into which the value is to be converted. Must not be {@code null}.
* @return The converted value. May be {@code null}.
*/
@Nullable
Object writeValue(@Nullable Object value, TypeInformation<?> type);

View File

@@ -55,7 +55,6 @@ public class RelationalMappingContext extends AbstractMappingContext<RelationalP
* Creates a new {@link RelationalMappingContext} using the given {@link NamingStrategy}.
*
* @param namingStrategy must not be {@literal null}.
* @param customizer must not be {@literal null}.
*/
public RelationalMappingContext(NamingStrategy namingStrategy) {