diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java index bc71ee132..db79114be 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java @@ -39,23 +39,33 @@ import com.datastax.driver.core.ResultSet; * {@link IllegalArgumentException}. * * @author Matthew T. Adams + * @author Mark Paluch * @param */ public abstract class AbstractResultSetConverter implements Converter { + private final static ResultSetToListConverter converter = new ResultSetToListConverter(); + /** * Converts the given value to this converter's type or throws {@link IllegalArgumentException}. */ protected abstract T doConvertSingleValue(Object object); + /** + * @return the target type. + */ protected abstract Class getType(); - protected ResultSetToListConverter converter = new ResultSetToListConverter(); - + /** + * @return surrogate value if the {@link ResultSet} is {@literal null}. + */ protected T getNullResultSetValue() { return null; } + /** + * @return surrogate value if the {@link ResultSet} is {@link ResultSet#isExhausted() exhausted}. + */ protected T getExhaustedResultSetValue() { return null; } @@ -100,8 +110,8 @@ public abstract class AbstractResultSetConverter implements Converter { - protected Converter rowConverter; + private final Converter rowConverter; /** * Create a new {@link ResultSetToArrayConverter} given a row {@link Converter}. @@ -39,24 +39,9 @@ public class ResultSetToArrayConverter implements Converter * @param rowConverter must not be {@literal null}. */ public ResultSetToArrayConverter(Converter rowConverter) { - setRowConverter(rowConverter); - } - - /** - * @return the row {@link Converter}. - */ - public Converter getRowConverter() { - return rowConverter; - } - - /** - * Set the row {@link Converter}. - * - * @param rowConverter must not be {@literal null}. - */ - public void setRowConverter(Converter rowConverter) { Assert.notNull(rowConverter, "Converter must not be null"); + this.rowConverter = rowConverter; } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/ResultSetToListConverter.java b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/ResultSetToListConverter.java index bb861a69f..6f50a86ef 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/ResultSetToListConverter.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/ResultSetToListConverter.java @@ -32,7 +32,7 @@ import com.datastax.driver.core.Row; */ public class ResultSetToListConverter implements Converter>> { - private Converter> rowConverter; + private final Converter> rowConverter; /** * Create a new {@link ResultSetToListConverter} using a default {@link RowToMapConverter}. @@ -47,22 +47,6 @@ public class ResultSetToListConverter implements Converter> rowConverter) { - setRowConverter(rowConverter); - } - - /** - * @return the row to map {@link Converter}. - */ - public Converter> getRowConverter() { - return rowConverter; - } - - /** - * Set the the row to map {@link Converter}. - * - * @param rowConverter must not be {@literal null}. - */ - public void setRowConverter(Converter> rowConverter) { Assert.notNull(rowConverter, "Converter must not be null");