DATAMONGO-1372 - Polishing.

Tiny formattings, collapsed if-clause into ternary operation.

Original pull request: #342.
This commit is contained in:
Oliver Gierke
2016-02-04 15:19:22 +01:00
parent b7131b7efc
commit 7e8ec21684
2 changed files with 5 additions and 13 deletions

View File

@@ -267,6 +267,7 @@ abstract class MongoConverters {
*/
@WritingConverter
public static enum CurrencyToStringConverter implements Converter<Currency, String> {
INSTANCE;
/*
@@ -275,12 +276,7 @@ abstract class MongoConverters {
*/
@Override
public String convert(Currency source) {
if (source == null) {
return null;
}
return source.getCurrencyCode();
return source == null ? null : source.getCurrencyCode();
}
}
@@ -292,6 +288,7 @@ abstract class MongoConverters {
*/
@ReadingConverter
public static enum StringToCurrencyConverter implements Converter<String, Currency> {
INSTANCE;
/*
@@ -300,12 +297,7 @@ abstract class MongoConverters {
*/
@Override
public Currency convert(String source) {
if (!StringUtils.hasText(source)) {
return null;
}
return Currency.getInstance(source);
return StringUtils.hasText(source) ? Currency.getInstance(source) : null;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2016 by the original author(s).
* Copyright 2011-2016 by the original author(s).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.