Skip to content

Commit 7e8ec21

Browse files
committed
DATAMONGO-1372 - Polishing.
Tiny formattings, collapsed if-clause into ternary operation. Original pull request: #342.
1 parent b7131b7 commit 7e8ec21

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public DBObject convert(NamedMongoScript source) {
267267
*/
268268
@WritingConverter
269269
public static enum CurrencyToStringConverter implements Converter<Currency, String> {
270+
270271
INSTANCE;
271272

272273
/*
@@ -275,12 +276,7 @@ public static enum CurrencyToStringConverter implements Converter<Currency, Stri
275276
*/
276277
@Override
277278
public String convert(Currency source) {
278-
279-
if (source == null) {
280-
return null;
281-
}
282-
283-
return source.getCurrencyCode();
279+
return source == null ? null : source.getCurrencyCode();
284280
}
285281
}
286282

@@ -292,6 +288,7 @@ public String convert(Currency source) {
292288
*/
293289
@ReadingConverter
294290
public static enum StringToCurrencyConverter implements Converter<String, Currency> {
291+
295292
INSTANCE;
296293

297294
/*
@@ -300,12 +297,7 @@ public static enum StringToCurrencyConverter implements Converter<String, Curren
300297
*/
301298
@Override
302299
public Currency convert(String source) {
303-
304-
if (!StringUtils.hasText(source)) {
305-
return null;
306-
}
307-
308-
return Currency.getInstance(source);
300+
return StringUtils.hasText(source) ? Currency.getInstance(source) : null;
309301
}
310302
}
311303
}

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoConvertersUnitTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2016 by the original author(s).
2+
* Copyright 2011-2016 by the original author(s).
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)