ModuleRequireInfo (Java SE 22 & JDK 22)
Description: declaration: module: java.base, package: java.lang.classfile.attribute, interface: ModuleRequireInfo
Keywords: java.lang.classfile.attribute.ModuleRequireInfo interface

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

# Interface ModuleRequireInfo

public sealed interface ModuleRequireInfo
`ModuleRequireInfo` is a preview API of the Java platform.
Programs can only use `ModuleRequireInfo` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a single "requires" declaration in the `ModuleAttribute`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default boolean`
  `has(AccessFlag flag)`
  Returns whether the specific access flag is set.
  `static ModuleRequireInfoPREVIEW`
  `of(ModuleEntryPREVIEW requires, int requiresFlags, Utf8EntryPREVIEW requiresVersion)`
  Returns a module requirement description.
  `static ModuleRequireInfoPREVIEW`
  `of(ModuleEntryPREVIEW requires, Collection<AccessFlag> requiresFlags, Utf8EntryPREVIEW requiresVersion)`
  Returns a module requirement description.
  `static ModuleRequireInfoPREVIEW`
  `of(ModuleDesc requires, int requiresFlags, String requiresVersion)`
  Returns a module requirement description.
  `static ModuleRequireInfoPREVIEW`
  `of(ModuleDesc requires, Collection<AccessFlag> requiresFlags, String requiresVersion)`
  Returns a module requirement description.
  `ModuleEntryPREVIEW`
  `requires()`
  Returns The module on which the current module depends.
  `default Set<AccessFlag>`
  `requiresFlags()`
  Returns the access flags.
  `int`
  `requiresFlagsMask()`
  Returns the flags associated with this require declaration, as a bit mask.
  `Optional<Utf8EntryPREVIEW>`
  `requiresVersion()`
  Returns the required version of the required module, if present.

- ## Method Details

  - ### requires

    ModuleEntryPREVIEW requires()
    Returns The module on which the current module depends.
    Returns:
      The module on which the current module depends

  - ### requiresFlagsMask

    int requiresFlagsMask()
    Returns the flags associated with this require declaration, as a bit mask. Valid flags include `ClassFile.ACC_TRANSITIVE`PREVIEW, `ClassFile.ACC_STATIC_PHASE`PREVIEW, `ClassFile.ACC_SYNTHETIC`PREVIEW and `ClassFile.ACC_MANDATED`PREVIEW
    Returns:
      the flags associated with this require declaration, as a bit mask

  - ### requiresFlags

    default Set<AccessFlag> requiresFlags()
    Returns the access flags.
    Returns:
      the access flags

  - ### requiresVersion

    Optional<Utf8EntryPREVIEW> requiresVersion()
    Returns the required version of the required module, if present.
    Returns:
      the required version of the required module, if present

  - ### has

    default boolean has(AccessFlag flag)
    Returns whether the specific access flag is set.
    Parameters:
      `flag` - the access flag
    Returns:
      whether the specific access flag is set

  - ### of

    static ModuleRequireInfoPREVIEW of(ModuleEntryPREVIEW requires, int requiresFlags, Utf8EntryPREVIEW requiresVersion)
    Returns a module requirement description.
    Parameters:
      `requires` - the required module
      `requiresFlags` - the require-specific flags
      `requiresVersion` - the required version
    Returns:
      a module requirement description

  - ### of

    static ModuleRequireInfoPREVIEW of(ModuleEntryPREVIEW requires, Collection<AccessFlag> requiresFlags, Utf8EntryPREVIEW requiresVersion)
    Returns a module requirement description.
    Parameters:
      `requires` - the required module
      `requiresFlags` - the require-specific flags
      `requiresVersion` - the required version
    Returns:
      a module requirement description

  - ### of

    static ModuleRequireInfoPREVIEW of(ModuleDesc requires, int requiresFlags, String requiresVersion)
    Returns a module requirement description.
    Parameters:
      `requires` - the required module
      `requiresFlags` - the require-specific flags
      `requiresVersion` - the required version
    Returns:
      a module requirement description

  - ### of

    static ModuleRequireInfoPREVIEW of(ModuleDesc requires, Collection<AccessFlag> requiresFlags, String requiresVersion)
    Returns a module requirement description.
    Parameters:
      `requires` - the required module
      `requiresFlags` - the require-specific flags
      `requiresVersion` - the required version
    Returns:
      a module requirement description