DATACASS-439 - Polishing.
Refactor static converter instances to enum types with a single instance.
This commit is contained in:
@@ -38,7 +38,7 @@ public class ResultSetToListConverter implements Converter<ResultSet, List<Map<S
|
||||
* Create a new {@link ResultSetToListConverter} using a default {@link RowToMapConverter}.
|
||||
*/
|
||||
public ResultSetToListConverter() {
|
||||
this(new RowToMapConverter());
|
||||
this(RowToMapConverter.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,9 +21,14 @@ import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
import com.datastax.driver.core.Row;
|
||||
|
||||
public class RowToArrayConverter implements Converter<Row, Object[]> {
|
||||
/**
|
||||
* Converter to convert {@link Row} to {@link Object} array.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public enum RowToArrayConverter implements Converter<Row, Object[]> {
|
||||
|
||||
protected RowToListConverter delegate = new RowToListConverter();
|
||||
INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
|
||||
@@ -31,7 +36,7 @@ public class RowToArrayConverter implements Converter<Row, Object[]> {
|
||||
@Override
|
||||
public Object[] convert(Row row) {
|
||||
|
||||
List<Object> list = delegate.convert(row);
|
||||
List<Object> list = RowToListConverter.INSTANCE.convert(row);
|
||||
return list == null ? null : list.toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ import com.datastax.driver.core.Row;
|
||||
* @author Antoine Toulme
|
||||
*/
|
||||
@ReadingConverter
|
||||
public class RowToListConverter implements Converter<Row, List<Object>> {
|
||||
public enum RowToListConverter implements Converter<Row, List<Object>> {
|
||||
|
||||
public final static RowToListConverter INSTANCE = new RowToListConverter();
|
||||
INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
|
||||
|
||||
@@ -34,9 +34,9 @@ import com.datastax.driver.core.Row;
|
||||
* @author Antoine Toulme
|
||||
*/
|
||||
@ReadingConverter
|
||||
public class RowToMapConverter implements Converter<Row, Map<String, Object>> {
|
||||
public enum RowToMapConverter implements Converter<Row, Map<String, Object>> {
|
||||
|
||||
public final static RowToMapConverter INSTANCE = new RowToMapConverter();
|
||||
INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
|
||||
|
||||
Reference in New Issue
Block a user