Skip to content

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.

hostRequired


scopeRequired


idRequired

  • Type: java.lang.String

Methods

Name Description
addDependency Add an ordering dependency on another Construct.
addError Adds an { "error": } metadata entry to this construct.
addInfo Adds a { "info": } metadata entry to this construct.
addMetadata Adds a metadata entry to this construct.
addWarning Adds a { "warning": } metadata entry to this construct.
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.

dependenciesRequired


addError

public void addError(java.lang.String message)

Adds an { "error": } metadata entry to this construct.

The toolkit will fail synthesis when errors are reported.

messageRequired

  • Type: java.lang.String

The error message.


addInfo

public void addInfo(java.lang.String message)

Adds a { "info": } metadata entry to this construct.

The toolkit will display the info message when apps are synthesized.

messageRequired

  • 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.

typeRequired

  • Type: java.lang.String

a string denoting the type of metadata.


dataRequired

  • Type: java.lang.Object

the value of the metadata (can be a Token).

If null/undefined, metadata will not be added.


fromFunctionOptional

  • 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": } metadata entry to this construct.

The toolkit will display the warning when an app is synthesized, or fail if run in --strict mode.

messageRequired

  • 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.

orderOptional


findChild

public IConstruct findChild(java.lang.String id)

Return a direct child by id.

Throws an error if the child is not found.

idRequired

  • 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.

keyRequired

  • Type: java.lang.String

The context key.


valueRequired

  • Type: java.lang.Object

The context value.


tryFindChild

public IConstruct tryFindChild(java.lang.String id)

Return a direct child by id, or undefined.

idRequired

  • 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.

keyRequired

  • 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.

childNameRequired

  • 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.

nodeRequired

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.

nodeRequired

The root of the construct tree.


optionsOptional

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.

nodeRequired

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".

childrenRequired

public java.util.List<IConstruct> getChildren();

All direct children of this construct.


dependenciesRequired

public java.util.List<Dependency> getDependencies();

Return all dependencies registered on this node or any of its children.


idRequired

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.


lockedRequired

public java.lang.Boolean getLocked();
  • Type: java.lang.Boolean

Returns true if this construct or the scopes in which it is defined are locked.


metadataRequired

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.


pathRequired

public java.lang.String getPath();
  • Type: java.lang.String

The full, absolute path of this construct in the tree.

Components are separated by '/'.


rootRequired

public IConstruct getRoot();

scopesRequired

public java.util.List<IConstruct> getScopes();

All parent scopes of this construct.


uniqueIdRequired

public java.lang.String getUniqueId();
  • Type: java.lang.String

A tree-global unique alphanumeric identifier for this construct.

Includes all components of the tree.


scopeOptional

public IConstruct getScope();

Returns the scope in which this construct is defined.

The value is undefined at the root of the construct scope tree.


defaultChildOptional

public IConstruct getDefaultChild();

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_SEPRequired

public java.lang.String getPathSep();
  • Type: java.lang.String

Separator used to delimit construct path components.