@Override
	public boolean applyTo(Program program) {
		EquateTable etable = program.getEquateTable();

		// First make sure there's an entry in the equates table for the equate
		// to be changed (there should always be one).
		Equate fromEquate = etable.getEquate(oldEquateName);
		if (fromEquate == null) {
			msg = "Equate not found: " + oldEquateName;
			return false;
		}

		// Get the value behind the equate...for later use.
		long value = fromEquate.getValue();

		// See if there are 0 references to this equate.  If so, remove
		// it from the table.
		if (fromEquate.getReferenceCount() <= 1) {
			etable.removeEquate(oldEquateName);
		}
		// Otherwise, there's at least one ref, so remove it.
		else {
			fromEquate.removeReference(addr, opIndex);
		}

		// If the new name is null, then this is an enum equate and we need to add the enum to the 
		// data type manager to generate the correct new formatted equate name.
		if (newEquateName == null && enoom != null) {
			this.enoom = (Enum) program.getDataTypeManager().addDataType(enoom, null);
			this.newEquateName = EquateManager.formatNameForEquate(enoom.getUniversalID(), value);
		}
		// Now move the ref to the new equate name.  To do this, first check the table
		// to see if an entry already exists for this name; if so, use it.  If not, create
		// one.
		Equate toEquate = etable.getEquate(newEquateName);
		if (toEquate == null) {
			try {
				toEquate = etable.createEquate(newEquateName, value);
			}
			catch (DuplicateNameException e) {
				throw new AssertException();
			}
			catch (InvalidInputException e) {
				msg = "Invalid equate name: " + newEquateName;
				return false;
			}
		}
		toEquate.addReference(addr, opIndex);
		return true;
	}
Constructor
<p>
Uses the fields in the enum as the new equate name for the scalar value. The new equate will
be linked back to the enum. NOTE: only the first field with the matching value will be used
as the new equate name.

@param oldEquateName the name of the equate that currently exists at the given location.
@param enoom the enoom to use for the enum equates.
@param addr the address of the equate.
@param opIndex the operand index of the equate.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/RenameEquateCmd.java