diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/AttributeHolder.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/AttributeHolder.java deleted file mode 100644 index 8fee3c2557..0000000000 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/AttributeHolder.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.javaoperatorsdk.operator.api.reconciler; - -import java.util.Optional; - -public interface AttributeHolder { - - Optional get(Object key, Class expectedType); - - T getMandatory(Object key, Class expectedType); - - Optional put(Object key, Object value); -} diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java index c2d853f38a..2f203fa07c 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java @@ -5,7 +5,7 @@ import io.javaoperatorsdk.operator.api.config.ConfigurationService; import io.javaoperatorsdk.operator.api.reconciler.dependent.ManagedDependentResourceContext; -public interface Context extends AttributeHolder { +public interface Context { Optional getRetryInfo(); @@ -15,13 +15,6 @@ default Optional getSecondaryResource(Class expectedType) { Optional getSecondaryResource(Class expectedType, String eventSourceName); - @Override - default T getMandatory(Object key, Class expectedType) { - return get(key, expectedType).orElseThrow(() -> new IllegalStateException( - "Mandatory attribute (key: " + key + ", type: " + expectedType.getName() - + ") is missing or not of the expected type")); - } - ConfigurationService getConfigurationService(); ManagedDependentResourceContext managedDependentResourceContext(); diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java index e4aa164d37..33f640789b 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java @@ -7,7 +7,7 @@ import io.javaoperatorsdk.operator.api.reconciler.dependent.ManagedDependentResourceContext; import io.javaoperatorsdk.operator.processing.Controller; -public class DefaultContext

extends MapAttributeHolder implements Context { +public class DefaultContext

implements Context { private final RetryInfo retryInfo; private final Controller

controller; diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceContext.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceContext.java index 026af88923..1a6c82bc6f 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceContext.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceContext.java @@ -11,7 +11,7 @@ * * @param

the type associated with the primary resource that is handled by your reconciler */ -public class EventSourceContext

extends MapAttributeHolder { +public class EventSourceContext

{ private final ResourceCache

primaryCache; private final ConfigurationService configurationService; diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/MapAttributeHolder.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/MapAttributeHolder.java deleted file mode 100644 index aee5ee7e54..0000000000 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/MapAttributeHolder.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.javaoperatorsdk.operator.api.reconciler; - -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; - -public class MapAttributeHolder { - - private final ConcurrentHashMap attributes = new ConcurrentHashMap(); - - public Optional get(Object key, Class expectedType) { - return Optional.ofNullable(attributes.get(key)) - .filter(expectedType::isInstance) - .map(expectedType::cast); - } - - public Optional put(Object key, Object value) { - if (value == null) { - return Optional.ofNullable(attributes.remove(key)); - } - return Optional.ofNullable(attributes.put(key, value)); - } - - public T getMandatory(Object key, Class expectedType) { - return get(key, expectedType).orElseThrow(() -> new IllegalStateException( - "Mandatory attribute (key: " + key + ", type: " + expectedType.getName() - + ") is missing or not of the expected type")); - } -}