Class ObjectFile

  • All Implemented Interfaces:
    software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable
    Direct Known Subclasses:
    IniFile, JsonFile, TomlFile, XmlFile, YamlFile

    @Generated(value="jsii-pacmak/1.96.0 (build 921e240)",
               date="2024-03-28T21:16:42.778Z")
    @Stability(Experimental)
    public abstract class ObjectFile
    extends FileBase
    (experimental) Represents an Object file.
    • Constructor Detail

      • ObjectFile

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

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

        @Stability(Experimental)
        protected ObjectFile​(@NotNull
                             software.constructs.IConstruct scope,
                             @NotNull
                             String filePath,
                             @NotNull
                             ObjectFileOptions options)
        Parameters:
        scope - This parameter is required.
        filePath - This parameter is required.
        options - This parameter is required.
    • Method Detail

      • addDeletionOverride

        @Stability(Experimental)
        public void addDeletionOverride​(@NotNull
                                        String path)
        (experimental) Syntactic sugar for addOverride(path, undefined).

        Parameters:
        path - The path of the value to delete. This parameter is required.
      • addOverride

        @Stability(Experimental)
        public void addOverride​(@NotNull
                                String path,
                                @NotNull
                                Object value)
        (experimental) Adds an override to the synthesized object file.

        If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

        To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

        For example,

         project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
         project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);
         

        would add the overrides

         "compilerOptions": {
           "alwaysStrict": true,
           "lib": [
             "dom",
             "dom.iterable",
             "esnext"
           ]
           ...
         }
         ...
         

        Parameters:
        path -
        • The path of the property, you can use dot notation to override values in complex types.
        This parameter is required.
        value -
        • The value.
        This parameter is required.
      • addToArray

        @Stability(Experimental)
        public void addToArray​(@NotNull
                               String path,
                               @NotNull
                               @NotNull Object... values)
        (experimental) Adds to an array in the synthesized object file.

        If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

        To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

        For example, with the following object file

         "compilerOptions": {
           "exclude": ["node_modules"],
           "lib": ["es2019"]
           ...
         }
         ...
         

         project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
         project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');
         

        would result in the following object file

         "compilerOptions": {
           "exclude": ["node_modules", "coverage"],
           "lib": ["es2019", "dom", "dom.iterable", "esnext"]
           ...
         }
         ...
         

        Parameters:
        path -
        • The path of the property, you can use dot notation to att to arrays in complex types.
        This parameter is required.
        values -
        • The values to add.
        This parameter is required.
      • patch

        @Stability(Experimental)
        public void patch​(@NotNull
                          @NotNull JsonPatch... patches)
        (experimental) Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

        For example, with the following object file

         "compilerOptions": {
           "exclude": ["node_modules"],
           "lib": ["es2019"]
           ...
         }
         ...
         

         project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
         project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));
         

        would result in the following object file

         "compilerOptions": {
           "exclude": ["node_modules", "coverage"],
           "lib": ["dom", "dom.iterable", "esnext"]
           ...
         }
         ...
         

        Parameters:
        patches -
        • The patch operations to apply.
        This parameter is required.
      • synthesizeContent

        @Stability(Experimental)
        @Nullable
        protected String synthesizeContent​(@NotNull
                                           IResolver resolver)
        (experimental) Implemented by derived classes and returns the contents of the file to emit.

        Specified by:
        synthesizeContent in class FileBase
        Parameters:
        resolver - This parameter is required.
        Returns:
        the content to synthesize or undefined to skip the file
      • getOmitEmpty

        @Stability(Experimental)
        @NotNull
        public Boolean getOmitEmpty()
        (experimental) Indicates if empty objects and arrays are omitted from the output object.