using pattern-matching instanceof where applicable

This commit is contained in:
Sebastian Stenzel
2021-03-17 09:22:16 +01:00
parent f73ae9759f
commit 4e075ab0ca
6 changed files with 10 additions and 12 deletions
@@ -33,8 +33,8 @@ class LicenseChecker {
try {
byte[] keyBytes = BaseEncoding.base64().decode(pemEncodedPublicKey);
PublicKey key = KeyFactory.getInstance("EC").generatePublic(new X509EncodedKeySpec(keyBytes));
if (key instanceof ECPublicKey) {
return (ECPublicKey) key;
if (key instanceof ECPublicKey k) {
return k;
} else {
throw new IllegalStateException("Key not an EC public key.");
}
@@ -173,8 +173,7 @@ public class VaultSettings {
@Override
public boolean equals(Object obj) {
if (obj instanceof VaultSettings && obj.getClass().equals(this.getClass())) {
VaultSettings other = (VaultSettings) obj;
if (obj instanceof VaultSettings other && obj.getClass().equals(this.getClass())) {
return Objects.equals(this.id, other.id);
} else {
return false;
@@ -355,8 +355,7 @@ public class Vault {
@Override
public boolean equals(Object obj) {
if (obj instanceof Vault && obj.getClass().equals(this.getClass())) {
final Vault other = (Vault) obj;
if (obj instanceof Vault other && obj.getClass().equals(this.getClass())) {
return Objects.equals(this.vaultSettings, other.vaultSettings);
} else {
return false;