Polish StringArrayPropertyEditor[Tests]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new StringArrayPropertyEditor with the default separator
|
||||
* Create a new {@code StringArrayPropertyEditor} with the default separator
|
||||
* (a comma).
|
||||
* <p>An empty text (without elements) will be turned into an empty array.
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new StringArrayPropertyEditor with the given separator.
|
||||
* Create a new {@code StringArrayPropertyEditor} with the given separator.
|
||||
* <p>An empty text (without elements) will be turned into an empty array.
|
||||
* @param separator the separator to use for splitting a {@link String}
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new StringArrayPropertyEditor with the given separator.
|
||||
* Create a new {@code StringArrayPropertyEditor} with the given separator.
|
||||
* @param separator the separator to use for splitting a {@link String}
|
||||
* @param emptyArrayAsNull {@code true} if an empty String array
|
||||
* is to be transformed into {@code null}
|
||||
@@ -81,19 +81,19 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new StringArrayPropertyEditor with the given separator.
|
||||
* Create a new {@code StringArrayPropertyEditor} with the given separator.
|
||||
* @param separator the separator to use for splitting a {@link String}
|
||||
* @param emptyArrayAsNull {@code true} if an empty String array
|
||||
* is to be transformed into {@code null}
|
||||
* @param trimValues {@code true} if the values in the parsed arrays
|
||||
* are to be trimmed of whitespace (default is true).
|
||||
* are to be trimmed of whitespace (default is true)
|
||||
*/
|
||||
public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull, boolean trimValues) {
|
||||
this(separator, null, emptyArrayAsNull, trimValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new StringArrayPropertyEditor with the given separator.
|
||||
* Create a new {@code StringArrayPropertyEditor} with the given separator.
|
||||
* @param separator the separator to use for splitting a {@link String}
|
||||
* @param charsToDelete a set of characters to delete, in addition to
|
||||
* trimming an input String. Useful for deleting unwanted line breaks:
|
||||
@@ -106,7 +106,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new StringArrayPropertyEditor with the given separator.
|
||||
* Create a new {@code StringArrayPropertyEditor} with the given separator.
|
||||
* @param separator the separator to use for splitting a {@link String}
|
||||
* @param charsToDelete a set of characters to delete, in addition to
|
||||
* trimming an input String. Useful for deleting unwanted line breaks:
|
||||
@@ -114,7 +114,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
* @param emptyArrayAsNull {@code true} if an empty String array
|
||||
* is to be transformed into {@code null}
|
||||
* @param trimValues {@code true} if the values in the parsed arrays
|
||||
* are to be trimmed of whitespace (default is true).
|
||||
* are to be trimmed of whitespace (default is true)
|
||||
*/
|
||||
public StringArrayPropertyEditor(
|
||||
String separator, @Nullable String charsToDelete, boolean emptyArrayAsNull, boolean trimValues) {
|
||||
@@ -128,13 +128,13 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
String[] array = StringUtils.delimitedListToStringArray(text, this.separator, this.charsToDelete);
|
||||
if (this.trimValues) {
|
||||
array = StringUtils.trimArrayElements(array);
|
||||
}
|
||||
if (this.emptyArrayAsNull && array.length == 0) {
|
||||
setValue(null);
|
||||
}
|
||||
else {
|
||||
if (this.trimValues) {
|
||||
array = StringUtils.trimArrayElements(array);
|
||||
}
|
||||
setValue(array);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user