Skip to content

Commit c49a24d

Browse files
committed
Run the format script
1 parent ae65588 commit c49a24d

3 files changed

Lines changed: 32 additions & 15 deletions

File tree

java/src/org/openqa/selenium/json/Json.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public String toJson(Object toConvert) {
4343

4444
public String toJson(Object toConvert, int maxDepth) {
4545
try (Writer writer = new StringWriter();
46-
JsonOutput jsonOutput = newOutput(writer)) {
46+
JsonOutput jsonOutput = newOutput(writer)) {
4747
jsonOutput.write(toConvert, maxDepth);
4848
return writer.toString();
4949
} catch (IOException e) {

java/src/org/openqa/selenium/json/JsonOutput.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,36 @@ public class JsonOutput implements Closeable {
128128
// common kinds of inputs next.
129129
Map<Predicate<Class<?>>, DepthAwareConsumer> builder = new LinkedHashMap<>();
130130
builder.put(Objects::isNull, (obj, maxDepth, depthRemaining) -> append("null"));
131-
builder.put(CharSequence.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(asString(obj)));
132-
builder.put(Number.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(obj.toString()));
133131
builder.put(
134-
Boolean.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append((Boolean) obj ? "true" : "false"));
132+
CharSequence.class::isAssignableFrom,
133+
(obj, maxDepth, depthRemaining) -> append(asString(obj)));
134+
builder.put(
135+
Number.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(obj.toString()));
136+
builder.put(
137+
Boolean.class::isAssignableFrom,
138+
(obj, maxDepth, depthRemaining) -> append((Boolean) obj ? "true" : "false"));
135139
builder.put(
136140
Date.class::isAssignableFrom,
137-
(obj, maxDepth, depthRemaining) -> append(String.valueOf(MILLISECONDS.toSeconds(((Date) obj).getTime()))));
141+
(obj, maxDepth, depthRemaining) ->
142+
append(String.valueOf(MILLISECONDS.toSeconds(((Date) obj).getTime()))));
138143
builder.put(
139144
Instant.class::isAssignableFrom,
140-
(obj, maxDepth, depthRemaining) -> append(asString(DateTimeFormatter.ISO_INSTANT.format((Instant) obj))));
141-
builder.put(Enum.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(asString(obj)));
145+
(obj, maxDepth, depthRemaining) ->
146+
append(asString(DateTimeFormatter.ISO_INSTANT.format((Instant) obj))));
147+
builder.put(
148+
Enum.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(asString(obj)));
142149
builder.put(
143-
File.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(((File) obj).getAbsolutePath()));
144-
builder.put(URI.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(asString((obj).toString())));
150+
File.class::isAssignableFrom,
151+
(obj, maxDepth, depthRemaining) -> append(((File) obj).getAbsolutePath()));
152+
builder.put(
153+
URI.class::isAssignableFrom,
154+
(obj, maxDepth, depthRemaining) -> append(asString((obj).toString())));
145155
builder.put(
146156
URL.class::isAssignableFrom,
147157
(obj, maxDepth, depthRemaining) -> append(asString(((URL) obj).toExternalForm())));
148-
builder.put(UUID.class::isAssignableFrom, (obj, maxDepth, depthRemaining) -> append(asString(obj.toString())));
158+
builder.put(
159+
UUID.class::isAssignableFrom,
160+
(obj, maxDepth, depthRemaining) -> append(asString(obj.toString())));
149161
builder.put(
150162
Level.class::isAssignableFrom,
151163
(obj, maxDepth, depthRemaining) -> append(asString(LogLevelMapping.getName((Level) obj))));
@@ -162,13 +174,16 @@ public class JsonOutput implements Closeable {
162174
// Special handling of asMap and toJson
163175
builder.put(
164176
cls -> getMethod(cls, "toJson") != null,
165-
(obj, maxDepth, depthRemaining) -> convertUsingMethod("toJson", obj, maxDepth, depthRemaining));
177+
(obj, maxDepth, depthRemaining) ->
178+
convertUsingMethod("toJson", obj, maxDepth, depthRemaining));
166179
builder.put(
167180
cls -> getMethod(cls, "asMap") != null,
168-
(obj, maxDepth, depthRemaining) -> convertUsingMethod("asMap", obj, maxDepth, depthRemaining));
181+
(obj, maxDepth, depthRemaining) ->
182+
convertUsingMethod("asMap", obj, maxDepth, depthRemaining));
169183
builder.put(
170184
cls -> getMethod(cls, "toMap") != null,
171-
(obj, maxDepth, depthRemaining) -> convertUsingMethod("toMap", obj, maxDepth, depthRemaining));
185+
(obj, maxDepth, depthRemaining) ->
186+
convertUsingMethod("toMap", obj, maxDepth, depthRemaining));
172187

173188
// And then the collection types
174189
builder.put(
@@ -385,7 +400,8 @@ private Method getMethod(Class<?> clazz, String methodName) {
385400
}
386401
}
387402

388-
private JsonOutput convertUsingMethod(String methodName, Object toConvert, int maxDepth, int depthRemaining) {
403+
private JsonOutput convertUsingMethod(
404+
String methodName, Object toConvert, int maxDepth, int depthRemaining) {
389405
try {
390406
Method method = getMethod(toConvert.getClass(), methodName);
391407
if (method == null) {

java/test/org/openqa/selenium/json/JsonOutputTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@ void shouldRespectMaxDepth(int maxDepth) {
764764

765765
Object finalValue = value;
766766

767-
assertThatExceptionOfType(JsonException.class).isThrownBy(() -> jsonOutput.write(finalValue, maxDepth));
767+
assertThatExceptionOfType(JsonException.class)
768+
.isThrownBy(() -> jsonOutput.write(finalValue, maxDepth));
768769
}
769770

770771
private String convert(Object toConvert) {

0 commit comments

Comments
 (0)