Record Class ModuleIdentifier

java.lang.Object
java.lang.Record
com.google.javascript.jscomp.ModuleIdentifier
Record Components:
name - Returns the user-provided name.
closureNamespace - Returns the Closure namespace name.
moduleName - Returns the module name.
All Implemented Interfaces:
Serializable

@Immutable public record ModuleIdentifier(String name, String closureNamespace, String moduleName) extends Record implements Serializable
Basic information on an entry point module.

Closure entry points are namespace names, while ES and CommonJS entry points are file paths which are normalized to a namespace name.

This class allows error messages to be based on the user-provided name rather than the normalized name.

See Also:
  • Constructor Details

    • ModuleIdentifier

      public ModuleIdentifier(String name, String closureNamespace, String moduleName)
      Creates an instance of a ModuleIdentifier record class.
      Parameters:
      name - the value for the name record component
      closureNamespace - the value for the closureNamespace record component
      moduleName - the value for the moduleName record component
  • Method Details

    • getName

      @InlineMe(replacement="this.name()") public String getName()
    • getClosureNamespace

      @InlineMe(replacement="this.closureNamespace()") public String getClosureNamespace()
    • getModuleName

      @InlineMe(replacement="this.moduleName()") public String getModuleName()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • forClosure

      public static ModuleIdentifier forClosure(String name)
      Returns an identifier for a Closure namespace.
      Parameters:
      name - The Closure namespace. It may be in one of the formats `name.space`, `goog:name.space` or `goog:moduleName:name.space`, where the latter specifies that the module and namespace names are different.
    • forFile

      public static ModuleIdentifier forFile(String filepath)
      Returns an identifier for an ES or CommonJS module.
      Parameters:
      filepath - Path to the ES or CommonJS module.
    • forFlagValue

      public static ModuleIdentifier forFlagValue(String flagValue)
      Returns an identifier for an --entry_point flag value.
      Parameters:
      flagValue - The flag value. If it is in one of the formats `goog:name.space` or `goog:moduleName:name.space`, it is interpreted as a Closure namespace. Otherwise, it is interpreted as the path to an ES or CommonJS module.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • closureNamespace

      public String closureNamespace()
      Returns the value of the closureNamespace record component.
      Returns:
      the value of the closureNamespace record component
    • moduleName

      public String moduleName()
      Returns the value of the moduleName record component.
      Returns:
      the value of the moduleName record component