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 Classes
Modifier and Type | Class | Description |
---|---|---|
static class | ModuleDescriptor.Requires.Modifier | A modifier on a module dependence. |
Methods
Modifier and Type | Method | Description |
---|---|---|
int | compareTo(ModuleDescriptor.Requires that) | Compares this module dependence to another. |
Optional<ModuleDescriptor.Version> | compiledVersion() | Returns the version of the module if recorded at compile-time. |
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. |
Optional<String> | rawCompiledVersion() | Returns the string with the possibly-unparseable version of the module if recorded at compile-time. |
String | toString() | Returns a string describing this module dependence. |
Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods
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
compiledVersion
public Optional<ModuleDescriptor.Version> compiledVersion()
Returns the version of the module if recorded at compile-time.
- Returns:
- The version of the module if recorded at compile-time, or an empty
Optional
if no version was recorded or the version string recorded is unparseable
rawCompiledVersion
public Optional<String> rawCompiledVersion()
Returns the string with the possibly-unparseable version of the module if recorded at compile-time.
- Returns:
- The string containing the version of the module if recorded at compile-time, or an empty
Optional
if no version was recorded - See Also:
compiledVersion()
compareTo
public int compareTo(ModuleDescriptor.Requires that)
Compares this module dependence to another.
Two Requires
objects are compared by comparing their module names lexicographically. Where the module names are equal then the sets of modifiers are compared in the same way that module modifiers are compared (see ModuleDescriptor.compareTo
). Where the module names are equal and the set of modifiers are equal then the version of the modules recorded at compile-time are compared. When comparing the versions recorded at compile-time then a dependence that has a recorded version is considered to succeed a dependence that does not have a recorded version. If both recorded versions are unparseable then the raw version strings are compared lexicographically.
- Specified by:
-
compareTo
in interfaceComparable<ModuleDescriptor.Requires>
- Parameters:
-
that
- The module dependence to compare - 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, set of modifiers are equal, and the compiled version of both modules is equal or not recorded for both modules.
This method satisfies the general contract of the Object.equals
method.
- Overrides:
-
equals
in classObject
- 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, modifiers, and the module version if recorded at compile time. It satisfies the general contract of the Object.hashCode
method.
- Overrides:
-
hashCode
in classObject
- 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 this module dependence.
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/module/ModuleDescriptor.Requires.html