Package org.spongepowered.asm.mixin.refmap

## Class ReferenceMapper

- java.lang.Object
- - org.spongepowered.asm.mixin.refmap.ReferenceMapper

- All Implemented Interfaces:
    `java.io.Serializable`, `IReferenceMapper`

      public final class ReferenceMapper
      extends java.lang.Object
      implements IReferenceMapper, java.io.Serializable

  Stores runtime information allowing field, method and type references which cannot be hard remapped by the reobfuscation process to be remapped in a "soft" manner at runtime. Refmaps are generated by the Annotation Processor at compile time and must be bundled with an obfuscated binary to allow obfuscated references in injectors and other String-defined targets to be remapped to the target obfsucation environment as appropriate. If the refmap is absent the environment is assumed to be deobfuscated (eg. dev-time) and injections and other transformations will fail if this is not the case.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static ReferenceMapper` | `DEFAULT_MAPPER` | Passthrough mapper, used as failover
    `static java.lang.String` | `DEFAULT_RESOURCE` | Resource to attempt to load if no source is specified explicitly

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ReferenceMapper()` | Create an empty refmap

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.String` | `addMapping​(java.lang.String context, java.lang.String className, java.lang.String reference, java.lang.String newReference)` | Add a mapping to this refmap
    `java.lang.String` | `getContext()` | Get the current context
    `java.lang.String` | `getResourceName()` | Get the resource name this refmap was loaded from (if available).
    `java.lang.String` | `getStatus()` | Get a user-readable "status" string for this refmap for use in error messages
    `boolean` | `isDefault()` | Get whether this mapper is defaulted.
    `static ReferenceMapper` | `read​(java.io.Reader reader, java.lang.String name)` | Read a new refmap instance from the specified reader
    `static ReferenceMapper` | `read​(java.lang.String resourcePath)` | Read a new refmap from the specified resource
    `java.lang.String` | `remap​(java.lang.String className, java.lang.String reference)` | Remap a reference for the specified owning class in the current context
    `java.lang.String` | `remapWithContext​(java.lang.String context, java.lang.String className, java.lang.String reference)` | Remap a reference for the specified owning class in the specified context
    `void` | `setContext​(java.lang.String context)` | Set the current remap context, can be null
    `void` | `write​(java.lang.Appendable writer)` | Write this refmap out to the specified writer

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_RESOURCE

          public static final java.lang.String DEFAULT_RESOURCE

      Resource to attempt to load if no source is specified explicitly
      See Also:
        Constant Field Values

    - #### DEFAULT_MAPPER

          public static final ReferenceMapper DEFAULT_MAPPER

      Passthrough mapper, used as failover

  - ### Constructor Detail

    - #### ReferenceMapper

          public ReferenceMapper()

      Create an empty refmap

  - ### Method Detail

    - #### isDefault

          public boolean isDefault()

      Description copied from interface: `IReferenceMapper`
      Get whether this mapper is defaulted. Use this flag rather than reference comparison to `DEFAULT_MAPPER` because of classloader shenanigans
      Specified by:
        `isDefault` in interface `IReferenceMapper`
      Returns:
        true if this mapper is a defaulted mapper

    - #### getResourceName

          public java.lang.String getResourceName()

      Description copied from interface: `IReferenceMapper`
      Get the resource name this refmap was loaded from (if available).
      Specified by:
        `getResourceName` in interface `IReferenceMapper`
      Returns:
        name of the resource

    - #### getStatus

          public java.lang.String getStatus()

      Description copied from interface: `IReferenceMapper`
      Get a user-readable "status" string for this refmap for use in error messages
      Specified by:
        `getStatus` in interface `IReferenceMapper`
      Returns:
        status message

    - #### getContext

          public java.lang.String getContext()

      Description copied from interface: `IReferenceMapper`
      Get the current context
      Specified by:
        `getContext` in interface `IReferenceMapper`
      Returns:
        current context key, can be null

    - #### setContext

          public void setContext​(java.lang.String context)

      Description copied from interface: `IReferenceMapper`
      Set the current remap context, can be null
      Specified by:
        `setContext` in interface `IReferenceMapper`
      Parameters:
        `context` - remap context

    - #### remap

          public java.lang.String remap​(java.lang.String className,
                                        java.lang.String reference)

      Description copied from interface: `IReferenceMapper`
      Remap a reference for the specified owning class in the current context
      Specified by:
        `remap` in interface `IReferenceMapper`
      Parameters:
        `className` - Owner class
        `reference` - Reference to remap
      Returns:
        remapped reference, returns original reference if not remapped

    - #### remapWithContext

          public java.lang.String remapWithContext​(java.lang.String context,
                                                   java.lang.String className,
                                                   java.lang.String reference)

      Description copied from interface: `IReferenceMapper`
      Remap a reference for the specified owning class in the specified context
      Specified by:
        `remapWithContext` in interface `IReferenceMapper`
      Parameters:
        `context` - Remap context to use
        `className` - Owner class
        `reference` - Reference to remap
      Returns:
        remapped reference, returns original reference if not remapped

    - #### addMapping

          public java.lang.String addMapping​(java.lang.String context,
                                             java.lang.String className,
                                             java.lang.String reference,
                                             java.lang.String newReference)

      Add a mapping to this refmap
      Parameters:
        `context` - Obfuscation context, can be null
        `className` - Class which owns this mapping, cannot be null
        `reference` - Reference to remap, cannot be null
        `newReference` - Remapped value, cannot be null
      Returns:
        replaced value, per the contract of `Map.put(K, V)`

    - #### write

          public void write​(java.lang.Appendable writer)

      Write this refmap out to the specified writer
      Parameters:
        `writer` - Writer to write to

    - #### read

          public static ReferenceMapper read​(java.lang.String resourcePath)

      Read a new refmap from the specified resource
      Parameters:
        `resourcePath` - Resource to read from
      Returns:
        new refmap or `DEFAULT_MAPPER` if reading fails

    - #### read

          public static ReferenceMapper read​(java.io.Reader reader,
                                             java.lang.String name)

      Read a new refmap instance from the specified reader
      Parameters:
        `reader` - Reader to read from
        `name` - Name of the resource being read from
      Returns:
        new refmap