DATAJDBC-113 - Polishing.

Applied changes from review.
Removed superfluous @ConstructorProperties annotations.
Fixed formatting.
Improved usage of generics.
This commit is contained in:
Jens Schauder
2017-09-05 07:59:54 +02:00
committed by Greg Turnquist
parent 9b7b1267bb
commit fd2ae05795
4 changed files with 8 additions and 13 deletions

View File

@@ -51,7 +51,6 @@ class EntityRowMapper<T> implements RowMapper<T> {
private final JdbcEntityOperations template;
private final JdbcPersistentProperty idProperty;
@java.beans.ConstructorProperties({ "entity", "conversions", "context", "template" })
public EntityRowMapper(JdbcPersistentEntity<T> entity, ConversionService conversions, JdbcMappingContext context,
JdbcEntityOperations template) {
@@ -137,7 +136,6 @@ class EntityRowMapper<T> implements RowMapper<T> {
@NonNull private final ConversionService conversionService;
@NonNull private final String prefix;
@java.beans.ConstructorProperties({ "resultSet", "conversionService", "prefix" })
private ResultSetParameterValueProvider(ResultSet resultSet, ConversionService conversionService, String prefix) {
this.resultSet = resultSet;

View File

@@ -126,21 +126,20 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
}
Class<?> type = p.getType();
if (Collection.class.isAssignableFrom(type))
return collectionPropertyAsStream(p, propertyAccessor);
return singlePropertyAsStream(p, propertyAccessor);
return Collection.class.isAssignableFrom(type) //
? collectionPropertyAsStream(p, propertyAccessor) //
: singlePropertyAsStream(p, propertyAccessor);
}
private Stream<Object> collectionPropertyAsStream(JdbcPersistentProperty p,
PersistentPropertyAccessor propertyAccessor) {
Object property = propertyAccessor.getProperty(p);
if (property == null) {
return Stream.empty();
}
return ((Collection<Object>) property).stream();
return property == null //
? Stream.empty() //
: ((Collection<Object>) property).stream();
}
private Stream<Object> singlePropertyAsStream(JdbcPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {

View File

@@ -36,7 +36,7 @@ import org.springframework.jdbc.support.JdbcUtils;
@UtilityClass
public class JdbcUtil {
private static final Map<Class, Integer> sqlTypeMappings = new HashMap<>();
private static final Map<Class<?>, Integer> sqlTypeMappings = new HashMap<>();
static {
@@ -63,7 +63,7 @@ public class JdbcUtil {
sqlTypeMappings.put(Timestamp.class, Types.TIMESTAMP);
}
public static int sqlTypeFor(Class type) {
public static int sqlTypeFor(Class<?> type) {
return sqlTypeMappings.keySet().stream() //
.filter(k -> k.isAssignableFrom(type)) //
.findFirst() //