Skip to content

Commit

Permalink
Remove an extra level in the class hierarchy.
Browse files Browse the repository at this point in the history
Closes #1574
  • Loading branch information
valery1707 authored and mp911de committed Sep 13, 2023
1 parent 5fd9951 commit 6d1d966
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 53 deletions.
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

0 comments on commit 6d1d966

Please sign in to comment.