Polishing contribution

Closes: gh-1196
This commit is contained in:
rstoyanchev
2025-05-29 15:02:34 +01:00
parent fbd114bd10
commit 831357be01
2 changed files with 5 additions and 24 deletions

View File

@@ -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 + "]";
}

View File

@@ -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]");
}
}