Skip to content

Commit

Permalink
Add consistent trimming behavior to converters
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Nov 22, 2019
1 parent 4638078 commit ab0a255
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
public class CidrAddressConverter implements Converter<CidrAddress> {

@Override
public CidrAddress convert(final String value) {
public CidrAddress convert(String value) {
value = value.trim();
if (value.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public DurationConverter() {
*/
@Override
public Duration convert(String value) {
value = value.trim();
if (value.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ public static <E extends Enum<E>> HyphenateEnumConverter<E> of(Class<E> enumType

@Override
public E convert(String value) {
if (value == null || value.trim().isEmpty()) {
value = value.trim();
if (value.isEmpty()) {
return null;
}

value = value.trim();
final String hyphenatedValue = hyphenate(value);
final Enum<?> enumValue = values.get(hyphenatedValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
public class InetAddressConverter implements Converter<InetAddress> {

@Override
public InetAddress convert(final String value) {
public InetAddress convert(String value) {
value = value.trim();
if (value.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
public class InetSocketAddressConverter implements Converter<InetSocketAddress> {

@Override
public InetSocketAddress convert(final String value) {
public InetSocketAddress convert(String value) {
value = value.trim();
if (value.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class MemorySizeConverter implements Converter<MemorySize> {
* @return {@link MemorySize} - a memory size represented by the given value
*/
public MemorySize convert(String value) {
value = value.trim();
if (value.isEmpty()) {
return null;
}
Expand Down

0 comments on commit ab0a255

Please sign in to comment.