Package ghidra.program.model.data

# Class DataTypeConflictHandler

java.lang.Object
ghidra.program.model.data.DataTypeConflictHandler

Direct Known Subclasses:
  `DWARFDataTypeConflictHandler`

public abstract class DataTypeConflictHandler extends Object
`DataTypeConflictHandler` provides the `DataTypeManager` with a handler that is used to provide a disposition when a datatype conflict is detected during `DataTypeManager.resolve(DataType, DataTypeConflictHandler)` processing.
Known Issue: resolve processing identifies a conflict on an outer datatype (e.g., Structure) before a resolve conflict decision has been made on its referenced datatypes. Depending upon the conflict handler used, this can result in duplicate conflict types once the full resolution is completed (see GP-3632).

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `DataTypeConflictHandler.ConflictResolutionPolicy`
  `ConflictResolutionPolicy` indicates the conflict resolution policy which should be applied when any conflict is encountered
  `static enum`
  `DataTypeConflictHandler.ConflictResult`
  `ConflictResult` indicates the resolution which should be applied to a specific conflict

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final DataTypeConflictHandler`
  `DEFAULT_HANDLER`
  `static final DataTypeConflictHandler`
  `KEEP_HANDLER`
  `static final DataTypeConflictHandler`
  `REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER`
  This `conflict handler` behaves similar to the `DEFAULT_HANDLER` with the difference being that a empty composite (see `DataType.isNotYetDefined()`) will be replaced by a similar non-empty composite type.
  `static DataTypeConflictHandler`
  `REPLACE_HANDLER`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DataTypeConflictHandler()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract DataTypeConflictHandler`
  `getSubsequentHandler()`
  Returns the appropriate handler for recursive resolve calls.
  `abstract DataTypeConflictHandler.ConflictResult`
  `resolveConflict(DataType addedDataType, DataType existingDataType)`
  Callback to handle conflicts in a datatype manager when new datatypes are added that have the same name as an existing datatype.
  `abstract boolean`
  `shouldUpdate(DataType sourceDataType, DataType localDataType)`
  Callback invoked when an associated dataType is being resolved and its local version of the dataType is different from the source archive's dataType.

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

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

- ## Field Details

  - ### DEFAULT_HANDLER

    public static final DataTypeConflictHandler DEFAULT_HANDLER

  - ### REPLACE_HANDLER

    public static DataTypeConflictHandler REPLACE_HANDLER

  - ### KEEP_HANDLER

    public static final DataTypeConflictHandler KEEP_HANDLER

  - ### REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER

    public static final DataTypeConflictHandler REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER
    This `conflict handler` behaves similar to the `DEFAULT_HANDLER` with the difference being that a empty composite (see `DataType.isNotYetDefined()`) will be replaced by a similar non-empty composite type. Alignment (e.g., packing) is not considered when determining conflict resolution.
    For datatypes originating from a source archive with matching ID, the replacment strategy will utilize the implementation with the latest timestamp.
    Unlike the `DEFAULT_HANDLER`, follow-on dependency datatype resolutions will retain the same conflict resolution strategy.

- ## Constructor Details

  - ### DataTypeConflictHandler

    public DataTypeConflictHandler()

- ## Method Details

  - ### resolveConflict

    public abstract DataTypeConflictHandler.ConflictResult resolveConflict(DataType addedDataType, DataType existingDataType)
    Callback to handle conflicts in a datatype manager when new datatypes are added that have the same name as an existing datatype. The implementer of this interface should do one of the following: return the addedDataType - which means to replace the existingDataType with the addedDataType (may throw exception if the datatypes are not compatible) return the existingDataType the addedDataType will be ignored and the existing dataType will be used. return a new DataType with a new name/category
    Parameters:
      `addedDataType` - the datatype being added.
      `existingDataType` - the datatype that exists with the same name/category as the one added
    Returns:
      an enum specify how to handle the conflict

  - ### shouldUpdate

    public abstract boolean shouldUpdate(DataType sourceDataType, DataType localDataType)
    Callback invoked when an associated dataType is being resolved and its local version of the dataType is different from the source archive's dataType. This method returns true if the local version should be updated to the archive's version of the dataType. Otherwise, the local dataType will be used (without updating) in the resolve operation.
    Parameters:
      `sourceDataType` -
      `localDataType` -
    Returns:
      true if the localDataType should be updated to be equivalent to the sourceDataType.

  - ### getSubsequentHandler

    public abstract DataTypeConflictHandler getSubsequentHandler()
    Returns the appropriate handler for recursive resolve calls.