Interface MappingTree

All Superinterfaces:
MappingTreeView
All Known Subinterfaces:
VisitableMappingTree
All Known Implementing Classes:
MemoryMappingTree

public interface MappingTree extends MappingTreeView
Mutable mapping tree.

All returned collections are to be assumed unmodifiable, unless explicitly stated otherwise.

  • Method Details

    • setSrcNamespace

      @Nullable @Nullable String setSrcNamespace(String namespace)
      Sets the tree's and all of its contained elements' source namespace name.

      If the passed namespace name equals an existing destination namespace's name, implementors may choose to switch the two namespaces around, analogous to MappingSourceNsSwitch. This has to be made clear in the implementation's documentation.

      Returns:
      The previous source namespace name, if present.
      Implementation Requirements:
      If switching with an existing destination namespace is requested, but not supported, an UnsupportedOperationException must be thrown.
    • setDstNamespaces

      List<String> setDstNamespaces(List<String> namespaces)
      Sets the tree's and all of its contained elements' destination namespace names.

      Can be used to reorder and/or drop destination namespaces, analogous to MappingDstNsReorder.

      Implementors may allow switching with the source namespace as well, analogous to MappingSourceNsSwitch. This has to be made clear in the implementation's documentation.

      Returns:
      The previous destination namespaces.
      Throws:
      IllegalArgumentException - If the passed namespace names contain duplicates.
      Implementation Requirements:
      If switching with the source namespace is requested, but not supported, an UnsupportedOperationException must be thrown.
    • getMetadata

      List<? extends MappingTree.MetadataEntry> getMetadata()
      Specified by:
      getMetadata in interface MappingTreeView
      Returns:
      A modifiable list of all metadata entries currently present in the tree. The list's order is equal to the order in which the entries have been originally added.
    • getMetadata

      List<? extends MappingTree.MetadataEntry> getMetadata(String key)
      Specified by:
      getMetadata in interface MappingTreeView
      Returns:
      An unmodifiable list of all currently present metadata entries whose key is equal to the passed one. The list's order is equal to the order in which the entries have been originally added.
    • addMetadata

      void addMetadata(MappingTree.MetadataEntry entry)
    • removeMetadata

      boolean removeMetadata(String key)
      Removes all metadata entries whose key is equal to the passed one.
      Returns:
      Whether any entries have been removed.
    • getClasses

      Collection<? extends MappingTree.ClassMapping> getClasses()
      Specified by:
      getClasses in interface MappingTreeView
    • getClass

      @Nullable @Nullable MappingTree.ClassMapping getClass(String srcName)
      Specified by:
      getClass in interface MappingTreeView
    • getClass

      @Nullable default @Nullable MappingTree.ClassMapping getClass(String name, int namespace)
      Specified by:
      getClass in interface MappingTreeView
    • addClass

      Merges a class mapping into the tree.
      Returns:
      The MappingTree.ClassMapping instance present in the tree after the merge has occurred. May or may not be the passed instance.
    • removeClass

      @Nullable @Nullable MappingTree.ClassMapping removeClass(String srcName)
      Removes a class mapping from the tree.
      Returns:
      The removed class mapping, if any.
    • propagateOuterClassNames

      default void propagateOuterClassNames(boolean processRemappedDstNames)
      Searches for inner classes whose effective destination name contains outer classes referenced via their source name, scans the tree for potential mappings for these enclosing classes, and applies the latters' destination names to the formers' fully qualified name.

      For example, it takes a class class_1$class_2 that doesn't have a mapping, tries to find class_1, which let's say has the mapping SomeClass, and changes the former's destination name to SomeClass$class_2.

      Equivalent of OuterClassNamePropagator, but more efficient since the tree's existing class map can be reused.

      Parameters:
      processRemappedDstNames - Whether already remapped destination names should also get their unmapped outer classes replaced.
    • propagateOuterClassNames

      default void propagateOuterClassNames(String srcNamespace, Collection<String> dstNamespaces, boolean processRemappedDstNames)
      Searches for inner classes whose effective destination name contains outer classes referenced via their source name, scans the tree for potential mappings for these enclosing classes, and applies the latters' destination names to the formers' fully qualified name.

      For example, it takes a class class_1$class_2 that doesn't have a mapping, tries to find class_1, which let's say has the mapping SomeClass, and changes the former's destination name to SomeClass$class_2.

      Equivalent of OuterClassNamePropagator, but more efficient since the tree's existing class map can be reused.

      Parameters:
      srcNamespace - The namespace where the original/unmapped outer class names originate from.
      dstNamespaces - The namespaces where outer class names shall be propagated.
      processRemappedDstNames - Whether already remapped destination names should also get their unmapped outer classes replaced.
    • getField

      @Nullable default @Nullable MappingTree.FieldMapping getField(String srcClsName, String srcName, @Nullable @Nullable String srcDesc)
      Specified by:
      getField in interface MappingTreeView
      See Also:
    • getField

      @Nullable default @Nullable MappingTree.FieldMapping getField(String clsName, String name, @Nullable @Nullable String desc, int namespace)
      Specified by:
      getField in interface MappingTreeView
    • getMethod

      @Nullable default @Nullable MappingTree.MethodMapping getMethod(String srcClsName, String srcName, @Nullable @Nullable String srcDesc)
      Specified by:
      getMethod in interface MappingTreeView
      See Also:
    • getMethod

      @Nullable default @Nullable MappingTree.MethodMapping getMethod(String clsName, String name, @Nullable @Nullable String desc, int namespace)
      Specified by:
      getMethod in interface MappingTreeView
      Parameters:
      desc - Can be either complete desc or parameter-only desc.