From 2f3498acca2ae04bb2b72200d437eaaaffffbefd Mon Sep 17 00:00:00 2001 From: Kevin Wooten Date: Thu, 6 May 2021 13:40:42 -0700 Subject: [PATCH] Remove use of optionals when calculating option overrides --- .../vault/runtime/VaultTransitManager.java | 22 ++++++++++++------- .../vault/transit/SignVerifyOptions.java | 18 +++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/VaultTransitManager.java b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/VaultTransitManager.java index c0e4e164882c1..93a629dc8a061 100644 --- a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/VaultTransitManager.java +++ b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/VaultTransitManager.java @@ -279,10 +279,10 @@ private void signBatch(String keyName, int keyVersion, List verifyBatch(String keyName, List Map zip(List keys, List values, Function f) return map; } + private T defaultIfNull(T value, T defaultValue) { + if (value != null) + return value; + return defaultValue; + } + } diff --git a/extensions/vault/runtime/src/main/java/io/quarkus/vault/transit/SignVerifyOptions.java b/extensions/vault/runtime/src/main/java/io/quarkus/vault/transit/SignVerifyOptions.java index 2a5d179986839..423e6fb611c4a 100644 --- a/extensions/vault/runtime/src/main/java/io/quarkus/vault/transit/SignVerifyOptions.java +++ b/extensions/vault/runtime/src/main/java/io/quarkus/vault/transit/SignVerifyOptions.java @@ -1,7 +1,5 @@ package io.quarkus.vault.transit; -import java.util.Optional; - public class SignVerifyOptions { private String signatureAlgorithm; @@ -9,8 +7,8 @@ public class SignVerifyOptions { private Boolean prehashed; private String marshalingAlgorithm; - public Optional getSignatureAlgorithm() { - return Optional.ofNullable(signatureAlgorithm); + public String getSignatureAlgorithm() { + return signatureAlgorithm; } public SignVerifyOptions setSignatureAlgorithm(String signatureAlgorithm) { @@ -18,8 +16,8 @@ public SignVerifyOptions setSignatureAlgorithm(String signatureAlgorithm) { return this; } - public Optional getHashAlgorithm() { - return Optional.ofNullable(hashAlgorithm); + public String getHashAlgorithm() { + return hashAlgorithm; } public SignVerifyOptions setHashAlgorithm(String hashAlgorithm) { @@ -27,8 +25,8 @@ public SignVerifyOptions setHashAlgorithm(String hashAlgorithm) { return this; } - public Optional getPrehashed() { - return Optional.ofNullable(prehashed); + public Boolean getPrehashed() { + return prehashed; } public SignVerifyOptions setPrehashed(Boolean prehashed) { @@ -36,8 +34,8 @@ public SignVerifyOptions setPrehashed(Boolean prehashed) { return this; } - public Optional getMarshalingAlgorithm() { - return Optional.ofNullable(marshalingAlgorithm); + public String getMarshalingAlgorithm() { + return marshalingAlgorithm; } public SignVerifyOptions setMarshalingAlgorithm(String marshalingAlgorithm) {