Class ExecutionAttribute<T>

java.lang.Object
software.amazon.awssdk.core.interceptor.ExecutionAttribute<T>
Type Parameters:
T - The type of data associated with this attribute.

public final class ExecutionAttribute<T> extends Object
An attribute attached to a particular execution, stored in ExecutionAttributes. This is typically used as a static final field in an ExecutionInterceptor:
 
  class MyExecutionInterceptor implements ExecutionInterceptor {
      private static final ExecutionAttribute<String> DATA = new ExecutionAttribute<>();

      public void beforeExecution(Context.BeforeExecution execution, ExecutionAttributes executionAttributes) {
          executionAttributes.put(DATA, "Request: " + execution.request());
      }

      public void afterExecution(Context.AfterExecution execution, ExecutionAttributes executionAttributes) {
          String data = executionAttributes.get(DATA); // Retrieve the value saved in beforeExecution.
      }
  }
 
 
  • Constructor Details

    • ExecutionAttribute

      public ExecutionAttribute(String name)
      Creates a new ExecutionAttribute bound to the provided type param.
      Parameters:
      name - Descriptive name for the attribute, used primarily for debugging purposes.
  • Method Details

    • derivedBuilder

      public static <T, U> ExecutionAttribute.DerivedAttributeBuilder<T,U> derivedBuilder(String name, Class<T> attributeType, ExecutionAttribute<U> realAttribute)
      Create an execution attribute whose value is derived from another attribute.

      Whenever this value is read, its value is read from a different "real" attribute, and whenever this value is written its value is written to the "real" attribute, instead.

      This is useful when new attributes are created to replace old attributes, but for backwards-compatibility those old attributes still need to be made available.

      Parameters:
      name - The name of the attribute to create
      attributeType - The type of the attribute being created
      realAttribute - The "real" attribute from which this attribute is derived
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      This override considers execution attributes with the same name to be the same object for the purpose of attribute merge.
      Overrides:
      equals in class Object
      Returns:
      boolean indicating whether the objects are equal or not.
    • hashCode

      public int hashCode()
      This override considers execution attributes with the same name to be the same object for the purpose of attribute merge.
      Overrides:
      hashCode in class Object
      Returns:
      hash code