Skip to content

Commit 831357b

Browse files
committed
Polishing contribution
Closes: gh-1196
1 parent fbd114b commit 831357b

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

spring-graphql/src/main/java/org/springframework/graphql/data/ArgumentValue.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,10 @@ public int hashCode() {
137137
return result;
138138
}
139139

140-
/**
141-
* Returns a non-empty string representation of this {@code ArgumentValue}
142-
* suitable for debugging.
143-
*
144-
* @return the string representation of this instance
145-
*/
146140
@Override
147141
public String toString() {
148-
if (this.omitted) {
149-
return "ArgumentValue.omitted";
150-
}
151-
if (this.value == null){
152-
return "ArgumentValue.empty";
153-
}
154-
return "ArgumentValue[%s]".formatted(this.value);
142+
String v = ((this.value != null) ? this.value.toString() : (this.omitted) ? "omitted" : "empty");
143+
return "ArgumentValue[" + v + "]";
155144
}
156145

157146

spring-graphql/src/test/java/org/springframework/graphql/data/ArgumentValueTests.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,9 @@ void ifPresentShouldSkipWhenOmitted() {
8181
}
8282

8383
@Test
84-
void toStringShouldReturnOmittedWhenOmitted() {
85-
assertThat(ArgumentValue.omitted()).hasToString("ArgumentValue.omitted");
86-
}
87-
88-
@Test
89-
void toStringShouldReturnEmptyWhenNull() {
90-
assertThat(ArgumentValue.ofNullable(null)).hasToString("ArgumentValue.empty");
91-
}
92-
93-
@Test
94-
void toStringShouldReturnValueWhenValue() {
84+
void toStringValue() {
85+
assertThat(ArgumentValue.omitted()).hasToString("ArgumentValue[omitted]");
86+
assertThat(ArgumentValue.ofNullable(null)).hasToString("ArgumentValue[empty]");
9587
assertThat(ArgumentValue.ofNullable("hello")).hasToString("ArgumentValue[hello]");
9688
}
9789
}

0 commit comments

Comments
 (0)