Class Node

  • All Implemented Interfaces:
    software.amazon.jsii.JsiiSerializable

    @Generated(value="jsii-pacmak/1.55.0 (build 3e0fc04)",
               date="2022-03-14T00:09:20.349Z")
    @Stability(Stable)
    public class Node
    extends software.amazon.jsii.JsiiObject
    Represents the construct node in the scope tree.
    • Field Detail

      • PATH_SEP

        @Stability(Stable)
        public static final String PATH_SEP
        Separator used to delimit construct path components.
    • Constructor Detail

      • Node

        protected Node​(software.amazon.jsii.JsiiObjectRef objRef)
      • Node

        protected Node​(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
      • Node

        @Stability(Stable)
        public Node​(@NotNull
                    Construct host,
                    @NotNull
                    IConstruct scope,
                    @NotNull
                    String id)
        Parameters:
        host - This parameter is required.
        scope - This parameter is required.
        id - This parameter is required.
    • Method Detail

      • of

        @Stability(Deprecated)
        @Deprecated
        @NotNull
        public static Node of​(@NotNull
                              IConstruct construct)
        Deprecated.
        use `construct.node` instead
        (deprecated) Returns the node associated with a construct.

        Parameters:
        construct - the construct. This parameter is required.
      • addDependency

        @Stability(Stable)
        public void addDependency​(@NotNull
                                  @NotNull IDependable... deps)
        Add an ordering dependency on another construct.

        An IDependable

        Parameters:
        deps - This parameter is required.
      • addMetadata

        @Stability(Stable)
        public void addMetadata​(@NotNull
                                String type,
                                @NotNull
                                Object data,
                                @Nullable
                                MetadataOptions options)
        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 CloudFormation templates to improve diagnostics.

        Parameters:
        type - a string denoting the type of metadata. This parameter is required.
        data - the value of the metadata (can be a Token). This parameter is required.
        options - options.
      • addMetadata

        @Stability(Stable)
        public void addMetadata​(@NotNull
                                String type,
                                @NotNull
                                Object data)
        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 CloudFormation templates to improve diagnostics.

        Parameters:
        type - a string denoting the type of metadata. This parameter is required.
        data - the value of the metadata (can be a Token). This parameter is required.
      • addValidation

        @Stability(Stable)
        public void addValidation​(@NotNull
                                  IValidation validation)
        Adds a validation to this construct.

        When node.validate() is called, the validate() method will be called on all validations and all errors will be returned.

        Parameters:
        validation - The validation object. This parameter is required.
      • findAll

        @Stability(Stable)
        @NotNull
        public List<IConstruct> findAll​(@Nullable
                                        ConstructOrder order)
        Return this construct and all of its children in the given order.

        Parameters:
        order -
      • findAll

        @Stability(Stable)
        @NotNull
        public List<IConstruct> findAll()
        Return this construct and all of its children in the given order.
      • findChild

        @Stability(Stable)
        @NotNull
        public IConstruct findChild​(@NotNull
                                    String id)
        Return a direct child by id.

        Throws an error if the child is not found.

        Parameters:
        id - Identifier of direct child. This parameter is required.
        Returns:
        Child with the given id.
      • lock

        @Stability(Stable)
        public void lock()
        Locks this construct from allowing more children to be added.

        After this call, no more children can be added to this construct or to any children.

      • setContext

        @Stability(Stable)
        public void setContext​(@NotNull
                               String key,
                               @NotNull
                               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.

        Parameters:
        key - The context key. This parameter is required.
        value - The context value. This parameter is required.
      • tryFindChild

        @Stability(Stable)
        @Nullable
        public IConstruct tryFindChild​(@NotNull
                                       String id)
        Return a direct child by id, or undefined.

        Parameters:
        id - Identifier of direct child. This parameter is required.
        Returns:
        the child if found, or undefined
      • tryGetContext

        @Stability(Stable)
        @NotNull
        public Object tryGetContext​(@NotNull
                                    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.

        Parameters:
        key - The context key. This parameter is required.
        Returns:
        The context value or `undefined` if there is no context value for thie key.
      • tryRemoveChild

        @Stability(Experimental)
        @NotNull
        public Boolean tryRemoveChild​(@NotNull
                                      String childName)
        (experimental) Remove the child with the given name, if present.

        Parameters:
        childName - This parameter is required.
        Returns:
        Whether a child with the given name was deleted.
      • validate

        @Stability(Stable)
        @NotNull
        public List<String> validate()
        Validates this construct.

        Invokes the validate() method on all validations added through addValidation().

        Returns:
        an array of validation error messages associated with this construct.
      • getAddr

        @Stability(Stable)
        @NotNull
        public String getAddr()
        Returns an opaque tree-unique address for this construct.

        Addresses are 42 characters hexadecimal strings. They begin with "c8" followed by 40 lowercase hexadecimal characters (0-9a-f).

        Addresses are calculated using a SHA-1 of the components of the construct path.

        To enable refactorings of construct trees, constructs with the ID Default will be excluded from the calculation. In those cases constructs in the same tree may have the same addreess.

        Example:

         c83a2846e506bcc5f10682b564084bca2d275709ee
         
      • getChildren

        @Stability(Stable)
        @NotNull
        public List<IConstruct> getChildren()
        All direct children of this construct.
      • getDependencies

        @Stability(Stable)
        @NotNull
        public List<IConstruct> getDependencies()
        Return all dependencies registered on this node (non-recursive).
      • getId

        @Stability(Stable)
        @NotNull
        public String getId()
        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 addr.

      • getLocked

        @Stability(Stable)
        @NotNull
        public Boolean getLocked()
        Returns true if this construct or the scopes in which it is defined are locked.
      • getMetadata

        @Stability(Stable)
        @NotNull
        public List<MetadataEntry> getMetadata()
        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.

      • getPath

        @Stability(Stable)
        @NotNull
        public String getPath()
        The full, absolute path of this construct in the tree.

        Components are separated by '/'.

      • getRoot

        @Stability(Stable)
        @NotNull
        public IConstruct getRoot()
        Returns the root of the construct tree.

        Returns:
        The root of the construct tree.
      • getScopes

        @Stability(Stable)
        @NotNull
        public List<IConstruct> getScopes()
        All parent scopes of this construct.

        Returns:
        a list of parent scopes. The last element in the list will always be the current construct and the first element will be the root of the tree.
      • getScope

        @Stability(Stable)
        @Nullable
        public IConstruct getScope()
        Returns the scope in which this construct is defined.

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

      • getDefaultChild

        @Stability(Stable)
        @Nullable
        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.

        Returns:
        a construct or undefined if there is no default child
      • setDefaultChild

        @Stability(Stable)
        public void setDefaultChild​(@Nullable
                                    IConstruct value)
        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.