Module java.base
Package java.lang.module

## Class ModuleDescriptor.Requires

- java.lang.Object
- - java.lang.module.ModuleDescriptor.Requires

All Implemented Interfaces:
  Comparable<ModuleDescriptor.Requires>

Enclosing class:
  ModuleDescriptor

    public static final class ModuleDescriptor.Requires
    extends Object
    implements Comparable<ModuleDescriptor.Requires>

A dependence upon a module

Since:
  9
See Also:
  `ModuleDescriptor.requires()`

### Nested Class Summary

Nested Classes
`static class` `ModuleDescriptor.Requires.Modifier` A modifier on a module dependence.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `compareTo(ModuleDescriptor.Requires that)` Compares this module dependence to another.
`boolean` `equals(Object ob)` Tests this module dependence for equality with the given object.
`int` `hashCode()` Computes a hash code for this module dependence.
`Set<ModuleDescriptor.Requires.Modifier>` `modifiers()` Returns the set of modifiers.
`String` `name()` Return the module name.
`String` `toString()` Returns a string describing module dependence.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### modifiers

    public Set<ModuleDescriptor.Requires.Modifier> modifiers()

Returns the set of modifiers.

Returns:
  A possibly-empty unmodifiable set of modifiers

#### name

    public String name()

Return the module name.

Returns:
  The module name

#### compareTo

    public int compareTo(ModuleDescriptor.Requires that)

Compares this module dependence to another.

Two `Requires` objects are compared by comparing their module name lexicographically. Where the module names are equal then the sets of modifiers are compared based on a value computed from the ordinal of each modifier.

Specified by:
  `compareTo` in interface `Comparable<ModuleDescriptor.Requires>`
Parameters:
  `that` - the object to be compared.
Returns:
  A negative integer, zero, or a positive integer if this module dependence is less than, equal to, or greater than the given module dependence

#### equals

    public boolean equals(Object ob)

Tests this module dependence for equality with the given object.

If the given object is not a `Requires` then this method returns `false`. Two module dependence objects are equal if the module names are equal and set of modifiers are equal.

This method satisfies the general contract of the `Object.equals` method.

Overrides:
  `equals` in class `Object`
Parameters:
  `ob` - the object to which this object is to be compared
Returns:
  `true` if, and only if, the given object is a module dependence that is equal to this module dependence
See Also:
  `Object.hashCode()`, `HashMap`

#### hashCode

    public int hashCode()

Computes a hash code for this module dependence.

The hash code is based upon the module name and modifiers. It satisfies the general contract of the `Object.hashCode` method.

Overrides:
  `hashCode` in class `Object`
Returns:
  The hash-code value for this module dependence
See Also:
  `Object.equals(java.lang.Object)`, `System.identityHashCode(java.lang.Object)`

#### toString

    public String toString()

Returns a string describing module dependence.

Overrides:
  `toString` in class `Object`
Returns:
  A string describing module dependence