Module java.base
Package java.lang.classfile.attributePREVIEW

# Interface ModuleAttribute.ModuleAttributeBuilder

Enclosing interface:
  `ModuleAttributePREVIEW`

public static sealed interface ModuleAttribute.ModuleAttributeBuilder
`ModuleAttributeBuilder` is a preview API of the Java platform.
Programs can only use `ModuleAttributeBuilder` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A builder for module attributes.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ModuleAttributePREVIEW`
  `build()`
  Builds module attribute.
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `exports(ModuleExportInfoPREVIEW exports)`
  Adds exported package
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `exports(PackageDesc pkge, int exportsFlagsMask, ModuleDesc... exportsToModules)`
  Adds exported package
  `default ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `exports(PackageDesc pkge, Collection<AccessFlag> exportsFlags, ModuleDesc... exportsToModules)`
  Adds exported package
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `moduleFlags(int flagsMask)`
  Sets the module flags
  `default ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `moduleFlags(AccessFlag... moduleFlags)`
  Sets the module flags
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `moduleName(ModuleDesc moduleName)`
  Sets the module name
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `moduleVersion(String version)`
  Sets the module flags
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `opens(ModuleOpenInfoPREVIEW opens)`
  Opens package
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `opens(PackageDesc pkge, int opensFlagsMask, ModuleDesc... opensToModules)`
  Opens package
  `default ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `opens(PackageDesc pkge, Collection<AccessFlag> opensFlags, ModuleDesc... opensToModules)`
  Opens package
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `provides(ModuleProvideInfoPREVIEW provides)`
  Declares provision of a service
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `provides(ClassDesc service, ClassDesc... implClasses)`
  Declares provision of a service
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `requires(ModuleRequireInfoPREVIEW requires)`
  Adds module requirement
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `requires(ModuleDesc module, int requiresFlagsMask, String version)`
  Adds module requirement
  `default ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `requires(ModuleDesc module, Collection<AccessFlag> requiresFlags, String version)`
  Adds module requirement
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `uses(ClassEntryPREVIEW uses)`
  Declares use of a service
  `ModuleAttribute.ModuleAttributeBuilderPREVIEW`
  `uses(ClassDesc service)`
  Declares use of a service

- ## Method Details

  - ### moduleName

    ModuleAttribute.ModuleAttributeBuilderPREVIEW moduleName(ModuleDesc moduleName)
    Sets the module name
    Parameters:
      `moduleName` - the module name
    Returns:
      this builder

  - ### moduleFlags

    ModuleAttribute.ModuleAttributeBuilderPREVIEW moduleFlags(int flagsMask)
    Sets the module flags
    Parameters:
      `flagsMask` - the module flags
    Returns:
      this builder

  - ### moduleFlags

    default ModuleAttribute.ModuleAttributeBuilderPREVIEW moduleFlags(AccessFlag... moduleFlags)
    Sets the module flags
    Parameters:
      `moduleFlags` - the module flags
    Returns:
      this builder

  - ### moduleVersion

    ModuleAttribute.ModuleAttributeBuilderPREVIEW moduleVersion(String version)
    Sets the module flags
    Parameters:
      `version` - the module version
    Returns:
      this builder

  - ### requires

    ModuleAttribute.ModuleAttributeBuilderPREVIEW requires(ModuleDesc module, int requiresFlagsMask, String version)
    Adds module requirement
    Parameters:
      `module` - the required module
      `requiresFlagsMask` - the requires flags
      `version` - the required module version
    Returns:
      this builder

  - ### requires

    default ModuleAttribute.ModuleAttributeBuilderPREVIEW requires(ModuleDesc module, Collection<AccessFlag> requiresFlags, String version)
    Adds module requirement
    Parameters:
      `module` - the required module
      `requiresFlags` - the requires flags
      `version` - the required module version
    Returns:
      this builder

  - ### requires

    ModuleAttribute.ModuleAttributeBuilderPREVIEW requires(ModuleRequireInfoPREVIEW requires)
    Adds module requirement
    Parameters:
      `requires` - the module require info
    Returns:
      this builder

  - ### exports

    ModuleAttribute.ModuleAttributeBuilderPREVIEW exports(PackageDesc pkge, int exportsFlagsMask, ModuleDesc... exportsToModules)
    Adds exported package
    Parameters:
      `pkge` - the exported package
      `exportsFlagsMask` - the export flags
      `exportsToModules` - the modules to export to
    Returns:
      this builder

  - ### exports

    default ModuleAttribute.ModuleAttributeBuilderPREVIEW exports(PackageDesc pkge, Collection<AccessFlag> exportsFlags, ModuleDesc... exportsToModules)
    Adds exported package
    Parameters:
      `pkge` - the exported package
      `exportsFlags` - the export flags
      `exportsToModules` - the modules to export to
    Returns:
      this builder

  - ### exports

    ModuleAttribute.ModuleAttributeBuilderPREVIEW exports(ModuleExportInfoPREVIEW exports)
    Adds exported package
    Parameters:
      `exports` - the module export info
    Returns:
      this builder

  - ### opens

    ModuleAttribute.ModuleAttributeBuilderPREVIEW opens(PackageDesc pkge, int opensFlagsMask, ModuleDesc... opensToModules)
    Opens package
    Parameters:
      `pkge` - the opened package
      `opensFlagsMask` - the open package flags
      `opensToModules` - the modules to open to
    Returns:
      this builder

  - ### opens

    default ModuleAttribute.ModuleAttributeBuilderPREVIEW opens(PackageDesc pkge, Collection<AccessFlag> opensFlags, ModuleDesc... opensToModules)
    Opens package
    Parameters:
      `pkge` - the opened package
      `opensFlags` - the open package flags
      `opensToModules` - the modules to open to
    Returns:
      this builder

  - ### opens

    ModuleAttribute.ModuleAttributeBuilderPREVIEW opens(ModuleOpenInfoPREVIEW opens)
    Opens package
    Parameters:
      `opens` - the module open info
    Returns:
      this builder

  - ### uses

    ModuleAttribute.ModuleAttributeBuilderPREVIEW uses(ClassDesc service)
    Declares use of a service
    Parameters:
      `service` - the service class used
    Returns:
      this builder
    Throws:
      `IllegalArgumentException` - if `service` represents a primitive type

  - ### uses

    ModuleAttribute.ModuleAttributeBuilderPREVIEW uses(ClassEntryPREVIEW uses)
    Declares use of a service
    Parameters:
      `uses` - the service class used
    Returns:
      this builder

  - ### provides

    ModuleAttribute.ModuleAttributeBuilderPREVIEW provides(ClassDesc service, ClassDesc... implClasses)
    Declares provision of a service
    Parameters:
      `service` - the service class provided
      `implClasses` - the implementation classes
    Returns:
      this builder
    Throws:
      `IllegalArgumentException` - if `service` or any of the `implClasses` represents a primitive type

  - ### provides

    ModuleAttribute.ModuleAttributeBuilderPREVIEW provides(ModuleProvideInfoPREVIEW provides)
    Declares provision of a service
    Parameters:
      `provides` - the module provides info
    Returns:
      this builder

  - ### build

    ModuleAttributePREVIEW build()
    Builds module attribute.
    Returns:
      the module attribute