Use pattern matching for instanceof where appropriate

See gh-31475
This commit is contained in:
dreis2211
2022-06-20 18:14:16 +02:00
committed by Andy Wilkinson
parent a7b98e7312
commit 5db04da275
278 changed files with 1049 additions and 1126 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -39,10 +39,9 @@ public final class Binding {
if (this == obj) {
return true;
}
if (!(obj instanceof Binding)) {
if (!(obj instanceof Binding binding)) {
return false;
}
Binding binding = (Binding) obj;
return Objects.equals(this.value, binding.value);
}

View File

@@ -55,11 +55,11 @@ public class InspectedContent implements Content {
@Override
public void writeTo(OutputStream outputStream) throws IOException {
if (this.content instanceof byte[]) {
FileCopyUtils.copy((byte[]) this.content, outputStream);
if (this.content instanceof byte[] bytes) {
FileCopyUtils.copy(bytes, outputStream);
}
else if (this.content instanceof File) {
InputStream inputStream = new FileInputStream((File) this.content);
else if (this.content instanceof File file) {
InputStream inputStream = new FileInputStream(file);
FileCopyUtils.copy(inputStream, outputStream);
}
else {