Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToOffsetDateTimeConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToStringConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToUuidConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToZonedDateTimeConverter;
import org.springframework.util.Assert;
import org.springframework.util.NumberUtils;

Expand All @@ -42,6 +38,7 @@
*
* @author Hebert Coelho
* @author Mark Paluch
* @author Valeriy Vyrva
*/
abstract class R2dbcConverters {

Expand Down Expand Up @@ -169,66 +166,66 @@ public T convert(Row source) {
return (object != null ? NumberUtils.convertNumberToTargetClass((Number) object, this.targetType) : null);
}
}
}

/**
* Simple singleton to convert {@link Row}s to their {@link OffsetDateTime} representation.
*
* @author Hebert Coelho
*/
public enum RowToOffsetDateTimeConverter implements Converter<Row, OffsetDateTime> {
/**
* Simple singleton to convert {@link Row}s to their {@link OffsetDateTime} representation.
*
* @author Hebert Coelho
*/
public enum RowToOffsetDateTimeConverter implements Converter<Row, OffsetDateTime> {

INSTANCE;
INSTANCE;

@Override
public OffsetDateTime convert(Row row) {
return row.get(0, OffsetDateTime.class);
}
@Override
public OffsetDateTime convert(Row row) {
return row.get(0, OffsetDateTime.class);
}
}

/**
* Simple singleton to convert {@link Row}s to their {@link String} representation.
*
* @author Hebert Coelho
*/
public enum RowToStringConverter implements Converter<Row, String> {
/**
* Simple singleton to convert {@link Row}s to their {@link String} representation.
*
* @author Hebert Coelho
*/
public enum RowToStringConverter implements Converter<Row, String> {

INSTANCE;
INSTANCE;

@Override
public String convert(Row row) {
return row.get(0, String.class);
}
@Override
public String convert(Row row) {
return row.get(0, String.class);
}
}

/**
* Simple singleton to convert {@link Row}s to their {@link UUID} representation.
*
* @author Hebert Coelho
*/
public enum RowToUuidConverter implements Converter<Row, UUID> {
/**
* Simple singleton to convert {@link Row}s to their {@link UUID} representation.
*
* @author Hebert Coelho
*/
public enum RowToUuidConverter implements Converter<Row, UUID> {

INSTANCE;
INSTANCE;

@Override
public UUID convert(Row row) {
return row.get(0, UUID.class);
}
@Override
public UUID convert(Row row) {
return row.get(0, UUID.class);
}
}

/**
* Simple singleton to convert {@link Row}s to their {@link ZonedDateTime} representation.
*
* @author Hebert Coelho
*/
public enum RowToZonedDateTimeConverter implements Converter<Row, ZonedDateTime> {
/**
* Simple singleton to convert {@link Row}s to their {@link ZonedDateTime} representation.
*
* @author Hebert Coelho
*/
public enum RowToZonedDateTimeConverter implements Converter<Row, ZonedDateTime> {

INSTANCE;
INSTANCE;

@Override
public ZonedDateTime convert(Row row) {
return row.get(0, ZonedDateTime.class);
}
@Override
public ZonedDateTime convert(Row row) {
return row.get(0, ZonedDateTime.class);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToLocalDateTimeConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToLocalTimeConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToOffsetDateTimeConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToStringConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToUuidConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToNumberConverterFactory.RowToZonedDateTimeConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToOffsetDateTimeConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToStringConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToUuidConverter;
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToZonedDateTimeConverter;

/**
* Unit tests for {@link R2dbcConverters}.
*
* @author Hebert Coelho
* @author Mark Paluch
* @author Valeriy Vyrva
*/
public class R2dbcConvertersUnitTests {

Expand Down