@Generated(value="jsii-pacmak/1.63.2 (build a8a8833)",
date="2022-08-02T20:25:24.263Z")
public class Annotations
extends software.amazon.jsii.JsiiObject
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()); } }
Modifier | Constructor and Description |
---|---|
protected |
Annotations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Annotations(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
void |
addDeprecation(java.lang.String api,
java.lang.String message)
Adds a deprecation warning for a specific API.
|
void |
addError(java.lang.String message)
Adds an { "error":
|
void |
addInfo(java.lang.String message)
Adds an info metadata entry to this construct.
|
void |
addWarning(java.lang.String message)
Adds a warning metadata entry to this construct.
|
static Annotations |
of(software.constructs.IConstruct scope)
Returns the annotations API for a construct scope.
|
protected Annotations(software.amazon.jsii.JsiiObjectRef objRef)
protected Annotations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public static Annotations of(software.constructs.IConstruct scope)
scope
- The scope. This parameter is required.public void addDeprecation(java.lang.String api, java.lang.String message)
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_DEPRECATIONS
is set, this method
will throw an error instead with the deprecation message.
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.public void addError(java.lang.String message)
The toolkit will fail deployment of any stack that has errors reported against it.
message
- The error message. This parameter is required.public void addInfo(java.lang.String message)
The CLI will display the info message when apps are synthesized.
message
- The info message. This parameter is required.public void addWarning(java.lang.String message)
The CLI will display the warning when an app is synthesized, or fail if run in --strict mode.
message
- The warning message. This parameter is required.