@Override
	public boolean applyTo(Program program) {
		Data data = program.getListing().getDefinedDataContaining(addr);
		Data dataComp = data.getComponent(componentPath);
		if (dataComp == null) {
			msg = "Component data not found";
			return false;
		}

		DataType parentDataType = dataComp.getParent().getBaseDataType();

		if (!(parentDataType instanceof Composite)) {
			msg = "Invalid command usage";
			return false;
		}

		if (newDataType instanceof FactoryDataType) {
			msg = "Factory data-type not allowed in structure or union: " + newDataType.getName();
			return false;
		}

		DataType existingDT = dataComp.getDataType();
		int index = dataComp.getComponentIndex();

		newDataType =
			DataUtilities.reconcileAppliedDataType(existingDT, newDataType, stackPointers);

		if (newDataType instanceof Dynamic) {
			msg = "Dynamically sized data-type not allowed: " + newDataType.getName();
			return false;
		}

		// Ensure that dynamically sized types adjust to the data type manager
		newDataType = program.getDataTypeManager().resolve(newDataType, null);

		try {
			if (parentDataType instanceof Structure) {
				Structure struct = (Structure) parentDataType;
				if (newDataType == DataType.DEFAULT) {
					struct.clearComponent(index);
				}
				else {
//			        MemBuffer memBuf = new ProgramStructureProviderContext(program,addr, 
//	    	        					struct, dataComp.getParentOffset());
					DataTypeInstance dti =
						DataTypeInstance.getDataTypeInstance(newDataType, -1, false);
					struct.replace(index, dti.getDataType(), dti.getLength());
				}
			}
			else if (parentDataType instanceof Union) {
				Union union = (Union) parentDataType;
				DataTypeComponent comp = union.getComponent(index);
				String comment = comp.getComment();
				String fieldName = comp.getFieldName();
				union.insert(index, newDataType);
				union.delete(index + 1);
				comp = union.getComponent(index);
				comp.setComment(comment);
				comp.setFieldName(fieldName);
			}

		}
		catch (Exception e) {
			msg = e.getMessage();
			return false;
		}
		return true;
	}
This is the same as {@link #CreateDataInStructureCmd(Address, int[], DataType)} except that
it allows the caller to control whether or not a pointer data type is created when a 
non-pointer data type is applied at a location that previously contained a pointer data
type.
 
@param addr the address of the structure in which to apply the given datatype.
@param componentPath the component path of the component where the datatype
will be applied.
@param dt the datatype to apply in the structure.
@param stackPointers if true simple pointer conversion is enabled 
(see {@link DataUtilities#reconcileAppliedDataType(DataType, DataType, boolean)}).
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateDataInStructureCmd.java