Skip to content

Commit 082eafb

Browse files
benelogschauder
authored andcommitted
DATAJDBC-355 - Remove unnecessary null check.
The source parameter must not be null according to Javadoc of Converter. See also: https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/convert/converter/Converter.html Original pull request: #146.
1 parent 6f18648 commit 082eafb

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryCustomConversionIntegrationTests.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
4040
import org.springframework.data.jdbc.testing.TestConfiguration;
4141
import org.springframework.data.repository.CrudRepository;
42-
import org.springframework.lang.Nullable;
4342
import org.springframework.test.context.ContextConfiguration;
4443
import org.springframework.test.context.junit4.rules.SpringClassRule;
4544
import org.springframework.test.context.junit4.rules.SpringMethodRule;
@@ -49,6 +48,7 @@
4948
* Tests storing and retrieving data types that get processed by custom conversions.
5049
*
5150
* @author Jens Schauder
51+
* @author Sanghyuk Jung
5252
*/
5353
@ContextConfiguration
5454
@Transactional
@@ -93,9 +93,9 @@ JdbcCustomConversions jdbcCustomConversions() {
9393
*
9494
* @Override
9595
* @Nullable
96-
* public BigDecimal convert(@Nullable String source) {
96+
* public BigDecimal convert(String source) {
9797
*
98-
* return source == null ? null : new BigDecimal(source);
98+
* return source == new BigDecimal(source);
9999
* }
100100
* }
101101
* </pre>
@@ -130,9 +130,9 @@ enum StringToBigDecimalConverter implements Converter<String, JdbcValue> {
130130
INSTANCE;
131131

132132
@Override
133-
public JdbcValue convert(@Nullable String source) {
133+
public JdbcValue convert(String source) {
134134

135-
Object value = source == null ? null : new BigDecimal(source);
135+
Object value = new BigDecimal(source);
136136
return JdbcValue.of(value, JDBCType.DECIMAL);
137137
}
138138

@@ -144,11 +144,7 @@ enum BigDecimalToString implements Converter<BigDecimal, String> {
144144
INSTANCE;
145145

146146
@Override
147-
public String convert(@Nullable BigDecimal source) {
148-
149-
if (source == null) {
150-
return null;
151-
}
147+
public String convert(BigDecimal source) {
152148

153149
return source.toString();
154150
}

0 commit comments

Comments
 (0)