ConstructNode
Represents the construct node in the scope tree.
Initializers
import com.aliyun.ros.cdk.core.ConstructNode;
new ConstructNode(Construct host, IConstruct scope, java.lang.String id);
Name | Type | Description |
---|---|---|
host |
Construct |
No description. |
scope |
IConstruct |
No description. |
id |
java.lang.String |
No description. |
host
Required
- Type: Construct
scope
Required
- Type: IConstruct
id
Required
- Type: java.lang.String
Methods
Name | Description |
---|---|
addDependency |
Add an ordering dependency on another Construct. |
addError |
Adds an { "error": |
addInfo |
Adds a { "info": |
addMetadata |
Adds a metadata entry to this construct. |
addWarning |
Adds a { "warning": |
findAll |
Return this construct and all of its children in the given order. |
findChild |
Return a direct child by id. |
setContext |
This can be used to set contextual values. |
tryFindChild |
Return a direct child by id, or undefined. |
tryGetContext |
Retrieves a value from tree context. |
tryRemoveChild |
Remove the child with the given name, if present. |
addDependency
public void addDependency(IDependable dependencies)
Add an ordering dependency on another Construct.
All constructs in the dependency's scope will be deployed before any construct in this construct's scope.
- Type: IDependable
addError
public void addError(java.lang.String message)
Adds an { "error":
The toolkit will fail synthesis when errors are reported.
- Type: java.lang.String
The error message.
addInfo
public void addInfo(java.lang.String message)
Adds a { "info":
The toolkit will display the info message when apps are synthesized.
- Type: java.lang.String
The info message.
addMetadata
public void addMetadata(java.lang.String type, java.lang.Object data)
public void addMetadata(java.lang.String type, java.lang.Object data, java.lang.Object fromFunction)
Adds a metadata entry to this construct.
Entries are arbitrary values and will also include a stack trace to allow tracing back to the code location for when the entry was added. It can be used, for example, to include source mapping in templates to improve diagnostics.
- Type: java.lang.String
a string denoting the type of metadata.
- Type: java.lang.Object
the value of the metadata (can be a Token).
If null/undefined, metadata will not be added.
- Type: java.lang.Object
a function under which to restrict the metadata entry's stack trace (defaults to this.addMetadata).
addWarning
public void addWarning(java.lang.String message)
Adds a { "warning":
The toolkit will display the warning when an app is synthesized, or fail if run in --strict mode.
- Type: java.lang.String
The warning message.
findAll
public java.util.List<IConstruct> findAll()
public java.util.List<IConstruct> findAll(ConstructOrder order)
Return this construct and all of its children in the given order.
- Type: ConstructOrder
findChild
public IConstruct findChild(java.lang.String id)
Return a direct child by id.
Throws an error if the child is not found.
- Type: java.lang.String
Identifier of direct child.
setContext
public void setContext(java.lang.String key, java.lang.Object value)
This can be used to set contextual values.
Context must be set before any children are added, since children may consult context info during construction. If the key already exists, it will be overridden.
- Type: java.lang.String
The context key.
- Type: java.lang.Object
The context value.
tryFindChild
public IConstruct tryFindChild(java.lang.String id)
Return a direct child by id, or undefined.
- Type: java.lang.String
Identifier of direct child.
tryGetContext
public java.lang.Object tryGetContext(java.lang.String key)
Retrieves a value from tree context.
Context is usually initialized at the root, but can be overridden at any point in the tree.
- Type: java.lang.String
The context key.
tryRemoveChild
public java.lang.Boolean tryRemoveChild(java.lang.String childName)
Remove the child with the given name, if present.
- Type: java.lang.String
Static Functions
Name | Description |
---|---|
prepare |
Invokes "prepare" on all constructs (depth-first, post-order) in the tree under node . |
synth |
Synthesizes a CloudAssembly from a construct tree. |
validate |
Invokes "validate" on all constructs in the tree (depth-first, pre-order) and returns the list of all errors. |
~~prepare
~~
import com.aliyun.ros.cdk.core.ConstructNode;
ConstructNode.prepare(ConstructNode node)
Invokes "prepare" on all constructs (depth-first, post-order) in the tree under node
.
- Type: ConstructNode
The root node.
~~synth
~~
import com.aliyun.ros.cdk.core.ConstructNode;
ConstructNode.synth(ConstructNode node),ConstructNode.synth(ConstructNode node, SynthesisOptions options)
Synthesizes a CloudAssembly from a construct tree.
- Type: ConstructNode
The root of the construct tree.
- Type: SynthesisOptions
Synthesis options.
validate
import com.aliyun.ros.cdk.core.ConstructNode;
ConstructNode.validate(ConstructNode node)
Invokes "validate" on all constructs in the tree (depth-first, pre-order) and returns the list of all errors.
An empty list indicates that there are no errors.
- Type: ConstructNode
The root node.
Properties
Name | Type | Description |
---|---|---|
children |
java.util.List<IConstruct> |
All direct children of this construct. |
dependencies |
java.util.List<Dependency> |
Return all dependencies registered on this node or any of its children. |
id |
java.lang.String |
The id of this construct within the current scope. |
locked |
java.lang.Boolean |
Returns true if this construct or the scopes in which it is defined are locked. |
metadata |
java.util.List |
An immutable array of metadata objects associated with this construct. |
path |
java.lang.String |
The full, absolute path of this construct in the tree. |
root |
IConstruct |
No description. |
scopes |
java.util.List<IConstruct> |
All parent scopes of this construct. |
uniqueId |
java.lang.String |
A tree-global unique alphanumeric identifier for this construct. |
scope |
IConstruct |
Returns the scope in which this construct is defined. |
defaultChild |
IConstruct |
Returns the child construct that has the id Default or Resource" . |
children
Required
public java.util.List<IConstruct> getChildren();
- Type: java.util.List<IConstruct>
All direct children of this construct.
dependencies
Required
public java.util.List<Dependency> getDependencies();
- Type: java.util.List<Dependency>
Return all dependencies registered on this node or any of its children.
id
Required
public java.lang.String getId();
- Type: java.lang.String
The id of this construct within the current scope.
This is a a scope-unique id. To obtain an app-unique id for this construct, use uniqueId
.
locked
Required
public java.lang.Boolean getLocked();
- Type: java.lang.Boolean
Returns true if this construct or the scopes in which it is defined are locked.
metadata
Required
public java.util.List<MetadataEntry> getMetadata();
- Type: java.util.List
An immutable array of metadata objects associated with this construct.
This can be used, for example, to implement support for deprecation notices, source mapping, etc.
path
Required
public java.lang.String getPath();
- Type: java.lang.String
The full, absolute path of this construct in the tree.
Components are separated by '/'.
root
Required
public IConstruct getRoot();
- Type: IConstruct
scopes
Required
public java.util.List<IConstruct> getScopes();
- Type: java.util.List<IConstruct>
All parent scopes of this construct.
uniqueId
Required
public java.lang.String getUniqueId();
- Type: java.lang.String
A tree-global unique alphanumeric identifier for this construct.
Includes all components of the tree.
scope
Optional
public IConstruct getScope();
- Type: IConstruct
Returns the scope in which this construct is defined.
The value is undefined
at the root of the construct scope tree.
defaultChild
Optional
public IConstruct getDefaultChild();
- Type: IConstruct
Returns the child construct that has the id Default
or Resource"
.
This is usually the construct that provides the bulk of the underlying functionality. Useful for modifications of the underlying construct that are not available at the higher levels. Override the defaultChild property.
This should only be used in the cases where the correct default child is not named 'Resource' or 'Default' as it should be.
If you set this to undefined, the default behavior of finding the child named 'Resource' or 'Default' will be used.
Constants
Name | Type | Description |
---|---|---|
PATH_SEP |
java.lang.String |
Separator used to delimit construct path components. |
PATH_SEP
Required
public java.lang.String getPathSep();
- Type: java.lang.String
Separator used to delimit construct path components.