Class Aspects

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.Aspects
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-18T17:54:11.293Z") @Stability(Stable) public class Aspects extends software.amazon.jsii.JsiiObject
Aspects can be applied to CDK tree scopes and can operate on the tree before synthesis.

Example:

 import software.amazon.awscdk.*;
 import software.constructs.Construct;
 import software.constructs.IConstruct;
 public class MyAspect implements IAspect {
     public void visit(IConstruct node) {
         if (node instanceof CfnResource && node.getCfnResourceType() == "Foo::Bar") {
             this.error(node, "we do not want a Foo::Bar resource");
         }
     }
     public void error(IConstruct node, String message) {
         Annotations.of(node).addError(message);
     }
 }
 public class MyStack extends Stack {
     public MyStack(Construct scope, String id) {
         super(scope, id);
         Stack stack = new Stack();
         CfnResource.Builder.create(stack, "Foo")
                 .type("Foo::Bar")
                 .properties(Map.of(
                         "Fred", "Thud"))
                 .build();
         Aspects.of(stack).add(new MyAspect());
     }
 }
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Aspects(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Aspects(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(IAspect aspect)
    Adds an aspect to apply this scope before synthesis.
    The list of aspects which were directly applied on this scope.
    static Aspects
    of(software.constructs.IConstruct scope)
    Returns the Aspects object associated with a construct scope.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • Aspects

      protected Aspects(software.amazon.jsii.JsiiObjectRef objRef)
    • Aspects

      protected Aspects(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
  • Method Details

    • of

      @Stability(Stable) @NotNull public static Aspects of(@NotNull software.constructs.IConstruct scope)
      Returns the Aspects object associated with a construct scope.

      Parameters:
      scope - The scope for which these aspects will apply. This parameter is required.
    • add

      @Stability(Stable) public void add(@NotNull IAspect aspect)
      Adds an aspect to apply this scope before synthesis.

      Parameters:
      aspect - The aspect to add. This parameter is required.
    • getAll

      @Stability(Stable) @NotNull public List<IAspect> getAll()
      The list of aspects which were directly applied on this scope.