Package ghidra.app.util.bin.format.dwarf4.next

# Class NameDeduper

java.lang.Object
ghidra.app.util.bin.format.dwarf4.next.NameDeduper

public class NameDeduper extends Object
Helper for allocating unique string names.

"Reserved names" are names that will be used by later calls to the de-duper.

"Used names" are names that are already allocated and are in use.

Reserved names only prevent re-use of a name when a name is being generated because of a collision with a "used name".

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NameDeduper()`
  Create a new name de-duper.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addReservedNames(Collection<String> additionalReservedNames)`
  Add names to the de-duper that will be used in a future call.
  `void`
  `addUsedNames(Collection<String> alreadyUsedNames)`
  Add names to the the de-duper that have already been used.
  `String`
  `getUniqueName(String name)`
  Confirms that the specified name is unique, or returns a generated name that is unique.
  `boolean`
  `isUniqueName(String name)`
  Returns true if the specified name hasn't been allocated yet.

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

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

- ## Constructor Details

  - ### NameDeduper

    public NameDeduper()
    Create a new name de-duper.

- ## Method Details

  - ### addUsedNames

    public void addUsedNames(Collection<String> alreadyUsedNames)
    Add names to the the de-duper that have already been used.
    Parameters:
      `alreadyUsedNames` -

  - ### addReservedNames

    public void addReservedNames(Collection<String> additionalReservedNames)
    Add names to the de-duper that will be used in a future call. These names do not block calls to confirm that a name is unique, but instead prevent the name from being used when an auto-generated name is created.
    Parameters:
      `additionalReservedNames` -

  - ### isUniqueName

    public boolean isUniqueName(String name)
    Returns true if the specified name hasn't been allocated yet.
    Parameters:
      `name` -
    Returns:

  - ### getUniqueName

    public String getUniqueName(String name)
    Confirms that the specified name is unique, or returns a generated name that is unique.
    Parameters:
      `name` - name to test
    Returns:
      `null` if specified name is already unique (and marks the specified name as used), or returns a new, unique generated name