Polishing contribution
Closes: gh-1196
This commit is contained in:
@@ -137,21 +137,10 @@ public final class ArgumentValue<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a non-empty string representation of this {@code ArgumentValue}
|
||||
* suitable for debugging.
|
||||
*
|
||||
* @return the string representation of this instance
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.omitted) {
|
||||
return "ArgumentValue.omitted";
|
||||
}
|
||||
if (this.value == null){
|
||||
return "ArgumentValue.empty";
|
||||
}
|
||||
return "ArgumentValue[%s]".formatted(this.value);
|
||||
String v = ((this.value != null) ? this.value.toString() : (this.omitted) ? "omitted" : "empty");
|
||||
return "ArgumentValue[" + v + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -81,17 +81,9 @@ class ArgumentValueTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void toStringShouldReturnOmittedWhenOmitted() {
|
||||
assertThat(ArgumentValue.omitted()).hasToString("ArgumentValue.omitted");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toStringShouldReturnEmptyWhenNull() {
|
||||
assertThat(ArgumentValue.ofNullable(null)).hasToString("ArgumentValue.empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toStringShouldReturnValueWhenValue() {
|
||||
void toStringValue() {
|
||||
assertThat(ArgumentValue.omitted()).hasToString("ArgumentValue[omitted]");
|
||||
assertThat(ArgumentValue.ofNullable(null)).hasToString("ArgumentValue[empty]");
|
||||
assertThat(ArgumentValue.ofNullable("hello")).hasToString("ArgumentValue[hello]");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user