@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:35.787Z") @Stability(value=Stable) public class Annotations extends software.amazon.jsii.JsiiObject
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());
}
}
| 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(String api,
String message)
Adds a deprecation warning for a specific API.
|
void |
addError(String message)
Adds an { "error":
|
void |
addInfo(String message)
Adds an info metadata entry to this construct.
|
void |
addWarning(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.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Annotations(software.amazon.jsii.JsiiObjectRef objRef)
protected Annotations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) @NotNull public static Annotations of(@NotNull software.constructs.IConstruct scope)
scope - The scope. This parameter is required.@Stability(value=Stable)
public void addDeprecation(@NotNull
String api,
@NotNull
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.@Stability(value=Stable)
public void addError(@NotNull
String message)
The toolkit will fail deployment of any stack that has errors reported against it.
message - The error message. This parameter is required.@Stability(value=Stable)
public void addInfo(@NotNull
String message)
The CLI will display the info message when apps are synthesized.
message - The info message. This parameter is required.@Stability(value=Stable)
public void addWarning(@NotNull
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.Copyright © 2022. All rights reserved.