From ccddcdcc3bf8c7a32f43c31877b6ca61a34b9d94 Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Wed, 4 Aug 2021 21:29:08 +0000 Subject: [PATCH] remove default key value --- .../google/api/gax/rpc/ApiCallContext.java | 21 +++++-------------- .../rpc/internal/ApiCallContextOptions.java | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java b/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java index 61ec4892d..79e4ef0e7 100644 --- a/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java +++ b/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java @@ -248,37 +248,26 @@ public interface ApiCallContext extends RetryingContext { * Return a new ApiCallContext with additional option merged into the present instance. Any * existing value of the key is overwritten. */ - @BetaApi( - "The surface for api call context options is not stable yet and may change in the future.") + @BetaApi("The surface for call context options is not stable yet and may change in the future.") ApiCallContext withOption(Key key, T value); /** Return the api call context option set for this context. */ @SuppressWarnings("unchecked") - @BetaApi( - "The surface for api call context options is not stable yet and may change in the future.") + @BetaApi("The surface for call context options is not stable yet and may change in the future.") T getOption(Key key); /** Key for api call context options key-value pair. */ final class Key { private final String name; - private final T defaultValue; - private Key(String name, T defaultValue) { + private Key(String name) { this.name = name; - this.defaultValue = defaultValue; } - /** - * Factory method for creating instances of {@link Key}. The default value of the key is null. - */ + /** Factory method for creating instances of {@link Key}. */ public static Key create(String name) { Preconditions.checkNotNull(name, "Key name cannot be null."); - return new Key<>(name, null); - } - - /** Returns the user supplied default value of the key. */ - public T getDefault() { - return defaultValue; + return new Key<>(name); } } } diff --git a/gax/src/main/java/com/google/api/gax/rpc/internal/ApiCallContextOptions.java b/gax/src/main/java/com/google/api/gax/rpc/internal/ApiCallContextOptions.java index 987e33736..b1b399f49 100644 --- a/gax/src/main/java/com/google/api/gax/rpc/internal/ApiCallContextOptions.java +++ b/gax/src/main/java/com/google/api/gax/rpc/internal/ApiCallContextOptions.java @@ -76,7 +76,7 @@ public ApiCallContextOptions withOption(Key key, T value) { public T getOption(Key key) { Preconditions.checkNotNull(key); if (!options.containsKey(key)) { - return key.getDefault(); + return null; } return (T) options.get(key); }