Class UnitNameTracker

java.lang.Object
megamek.common.units.UnitNameTracker

public class UnitNameTracker extends Object
Provides a means to track unit names for collisions. This API is not thread safe.
  • Constructor Details

    • UnitNameTracker

      public UnitNameTracker()
  • Method Details

    • add

      public void add(Entity entity)
      Adds an entity to the name tracker.
      Parameters:
      entity - The entity to track for name collisions.
    • remove

      public boolean remove(Entity entity)
      Removes an entity from the name tracker.
      Parameters:
      entity - The entity to remove from the name tracker.
      Returns:
      A value indicating whether the entity was removed.
    • remove

      public boolean remove(Entity entity, @Nullable Consumer<Entity> onEntityUpdated)
      Removes an entity from the name tracker.
      Parameters:
      entity - The entity to remove from the name tracker.
      onEntityUpdated - An optional function to execute when an entity is updated due to a duplicate name change.
      Returns:
      A value indicating whether the entity was removed.
    • clear

      public void clear()
      Clears the unit name tracker of all tracked entities.