Package software.amazon.awscdk.core
Class Annotations
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.core.Annotations
- All Implemented Interfaces:
- software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
           date="2023-06-19T16:29:54.779Z")
@Stability(Stable)
public class Annotations
extends software.amazon.jsii.JsiiObject
Includes API for attaching annotations such as warning messages to constructs.
 
Example:
 import software.amazon.awscdk.core.*;
 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 SummaryNested classes/interfaces inherited from class software.amazon.jsii.JsiiObjectsoftware.amazon.jsii.JsiiObject.InitializationMode
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAnnotations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedAnnotations(software.amazon.jsii.JsiiObjectRef objRef) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddDeprecation(String api, String message) Adds a deprecation warning for a specific API.voidAdds an { "error":} metadata entry to this construct. voidAdds an info metadata entry to this construct.voidaddWarning(String message) Adds a warning metadata entry to this construct.static Annotationsof(software.constructs.IConstruct scope) Returns the annotations API for a construct scope.Methods inherited from class software.amazon.jsii.JsiiObjectjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable$jsii$toJson
- 
Constructor Details- 
Annotationsprotected Annotations(software.amazon.jsii.JsiiObjectRef objRef) 
- 
Annotationsprotected Annotations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) 
 
- 
- 
Method Details- 
of@Stability(Stable) @NotNull public static Annotations of(@NotNull software.constructs.IConstruct scope) Returns the annotations API for a construct scope.- Parameters:
- scope- The scope. This parameter is required.
 
- 
addDeprecationAdds a deprecation warning for a specific API.Deprecations will be added only once per construct as a warning and will be deduplicated based on the api.If the environment variable CDK_BLOCK_DEPRECATIONSis set, this method will throw an error instead with the deprecation message.- Parameters:
- api- The API being deprecated in the format- module.Class.property(e.g.- @aws-cdk/core.Construct.node). This parameter is required.
- message- The deprecation message to display, with information about alternatives. This parameter is required.
 
- 
addErrorAdds an { "error":} metadata entry to this construct. The toolkit will fail deployment of any stack that has errors reported against it. - Parameters:
- message- The error message. This parameter is required.
 
- 
addInfoAdds an info metadata entry to this construct.The CLI will display the info message when apps are synthesized. - Parameters:
- message- The info message. This parameter is required.
 
- 
addWarningAdds a warning metadata entry to this construct.The CLI will display the warning when an app is synthesized, or fail if run in --strict mode. - Parameters:
- message- The warning message. This parameter is required.
 
 
-