Interface ModuleInfoDescriptor


public interface ModuleInfoDescriptor
Provides the basic formation for module-info.java creation and manipulation.
See Also:
  • Field Details

    • DEFAULT_MODULE_NAME

      static final String DEFAULT_MODULE_NAME
      The default module name (i.e., "unnamed").
      See Also:
    • DEFAULT_TEST_SUFFIX

      static final String DEFAULT_TEST_SUFFIX
      The default suffix on the module name for a test module. This suffix will be appended to the module name of the main module.
      See Also:
    • MODULE_INFO_NAME

      static final String MODULE_INFO_NAME
      The base module-info name.
      See Also:
    • DEFAULT_MODULE_INFO_JAVA_NAME

      static final String DEFAULT_MODULE_INFO_JAVA_NAME
      The java module-info name.
      See Also:
  • Method Details

    • name

      String name()
      The module name.
      Returns:
      the module name
    • templateName

      String templateName()
      The template name to apply. The default is TemplateHelper.DEFAULT_TEMPLATE_NAME.
      Returns:
      the template name
    • headerComment

      Optional<String> headerComment()
      The header (i.e., copyright) comment - will appear at the very start of the output.
      Returns:
      the header comment
    • descriptionComment

      Optional<String> descriptionComment()
      The description comment - will appear directly above the module's name().
      Returns:
      the description comment
    • ordering

      The ordering applied.
      Returns:
      the ordering
    • items

      The items contained by this module-info.
      Returns:
      the items
    • isUnnamed

      default boolean isUnnamed()
      Returns true if the name currently set is the same as the DEFAULT_MODULE_NAME.
      Returns:
      true if the current name is the default name
    • mergeCreate

      default ModuleInfoDescriptor mergeCreate(ModuleInfoDescriptor another)
      Provides the ability to create a new merged descriptor using this as the basis, and then combining another into it in order to create a new descriptor.
      Parameters:
      another - the other descriptor to merge
      Returns:
      the merged descriptor
    • addIfAbsent

      static boolean addIfAbsent(io.helidon.pico.tools.DefaultModuleInfoDescriptor.Builder builder, String target, Supplier<ModuleInfoItem> itemSupplier)
      Takes a builder, and if the target does not yet exist, will add the new module info item from the supplier.
      Parameters:
      builder - the fluent builder
      target - the target to check for existence for
      itemSupplier - the item to add which presumably has the same target as above
      Returns:
      true if added
    • create

      static ModuleInfoDescriptor create(Path path)
      Loads and creates the module-info descriptor given its source file location.
      Parameters:
      path - the source path location for the module-info descriptor
      Returns:
      the module-info descriptor
      Throws:
      ToolsException - if there is any exception encountered
    • create

      static ModuleInfoDescriptor create(Path path, ModuleInfoDescriptor.Ordering ordering)
      Loads and creates the module-info descriptor given its source file location and preferred ordering scheme.
      Parameters:
      path - the source path location for the module-info descriptor
      ordering - the ordering to apply
      Returns:
      the module-info descriptor
      Throws:
      ToolsException - if there is any exception encountered
    • create

      static ModuleInfoDescriptor create(InputStream is)
      Loads and creates the module-info descriptor given its source input stream.
      Parameters:
      is - the source file input stream
      Returns:
      the module-info descriptor
      Throws:
      ToolsException - if there is any exception encountered
    • create

      Loads and creates the module-info descriptor given its input stream.
      Parameters:
      is - the source file location
      ordering - the ordering to apply
      Returns:
      the module-info descriptor
      Throws:
      ToolsException - if there is any exception encountered
    • create

      static ModuleInfoDescriptor create(String moduleInfo)
      Loads and creates the module-info descriptor given its literal source.
      Parameters:
      moduleInfo - the source
      Returns:
      the module-info descriptor
      Throws:
      ToolsException - if there is any exception encountered
    • create

      static ModuleInfoDescriptor create(String moduleInfo, ModuleInfoDescriptor.Ordering ordering)
      Loads and creates the module-info descriptor given its literal source and preferred ordering scheme.
      Parameters:
      moduleInfo - the source
      ordering - the ordering to apply
      Returns:
      the module-info descriptor
      Throws:
      ToolsException - if there is any exception encountered
    • save

      default void save(Path path)
      Saves the descriptor source to the provided path.
      Parameters:
      path - the target path
      Throws:
      ToolsException - if there is any exception encountered
    • first

      default Optional<ModuleInfoItem> first(String target)
      Retrieves the first item matching the target requested.
      Parameters:
      target - the target name to find
      Returns:
      the item or empty if not found
    • firstUnqualifiedPackageExport

      default Optional<String> firstUnqualifiedPackageExport()
      Returns the first export found in the module that is unqualified with any extra to declaration.
      Returns:
      the first package that is exported from this module, or empty if there are no exports appropriate
    • contents

      default String contents()
      Provides the content of the description appropriate to write out.
      Returns:
      the contents (source code body) for this descriptor
    • contents

      default String contents(boolean wantAnnotation)
      Provides the content of the description appropriate to write out.
      Parameters:
      wantAnnotation - flag determining whether the Generated annotation comment should be present
      Returns:
      the contents (source code body) for this descriptor
    • usesExternalContract

      static ModuleInfoItem usesExternalContract(Class<?> externalContract)
      Creates a new item declaring a uses external contract definition from this module descriptor.
      Parameters:
      externalContract - the external contract definition
      Returns:
      the item created
    • usesExternalContract

      static ModuleInfoItem usesExternalContract(TypeName externalContract)
      Creates a new item declaring a uses external contract definition from this module descriptor.
      Parameters:
      externalContract - the external contract definition
      Returns:
      the item created
    • usesExternalContract

      static ModuleInfoItem usesExternalContract(String externalContract)
      Creates a new item declaring a uses external contract definition from this module descriptor.
      Parameters:
      externalContract - the external contract definition
      Returns:
      the item created
    • providesContract

      static ModuleInfoItem providesContract(String contract, String with)
      Creates a new item declaring it to provide some contract from this module definition, along with a 'with' declaration.
      Parameters:
      contract - the contract definition being provided
      with - the with part
      Returns:
      the item created
    • requiresModuleName

      static ModuleInfoItem requiresModuleName(String moduleName)
      Creates a new item declaring a requires on an external module usage from this module descriptor.
      Parameters:
      moduleName - the module name to require
      Returns:
      the item created
    • requiresModuleName

      static ModuleInfoItem requiresModuleName(String moduleName, boolean isTransitive, boolean isStatic, List<String> comments)
      Creates a new item declaring a requires on an external module usage from this module descriptor, that is extended to use additional item attributes.
      Parameters:
      moduleName - the module name to require
      isTransitive - true if the requires declaration is transitive
      isStatic - true if the requires declaration is static
      comments - any comments to ascribe to the item
      Returns:
      the item created
    • exportsPackage

      static ModuleInfoItem exportsPackage(TypeName typeName)
      Creates a new item exports on a package from this module descriptor.
      Parameters:
      typeName - the type name exported
      Returns:
      the item created
    • exportsPackage

      static ModuleInfoItem exportsPackage(String pkg)
      Creates a new item exports on a package from this module descriptor.
      Parameters:
      pkg - the package name exported
      Returns:
      the item created
    • exportsPackage

      static ModuleInfoItem exportsPackage(String contract, String to)
      Creates a new item exports on a package from this module descriptor, along with a 'to' declaration.
      Parameters:
      contract - the contract definition being exported
      to - the to part
      Returns:
      the item created