Package ghidra.app.util.opinion

# Class Loaded<T extends DomainObject>

java.lang.Object
ghidra.app.util.opinion.Loaded<T>

Type Parameters:
  `T` - The type of `DomainObject` that was loaded

public class Loaded<T extends DomainObject> extends Object
A loaded `DomainObject` produced by a `Loader`. In addition to storing the loaded `DomainObject`, it also stores the `Loader`'s desired name and project folder path for the loaded `DomainObject`, should it get saved to a project.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Loaded(T domainObject, String name, String projectFolderPath)`
  Creates a new `Loaded` object

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `getDomainObject()`
  Gets the loaded `DomainObject`
  `String`
  `getName()`
  Gets the name of the loaded `DomainObject`.
  `String`
  `getProjectFolderPath()`
  Gets the project folder path this will get saved to during a `save(Project, MessageLog, TaskMonitor)` operation.
  `DomainFile`
  `getSavedDomainFile()`
  Gets the loaded `DomainObject`'s associated `DomainFile` that was `saved`
  `void`
  `release(Object consumer)`
  Notify the loaded `DomainObject` that the specified consumer is no longer using it.
  `DomainFile`
  `save(Project project, MessageLog messageLog, TaskMonitor monitor)`
  Saves the loaded `DomainObject` to the given `Project` at this object's project folder path, using this object's name.
  `void`
  `setProjectFolderPath(String projectFolderPath)`
  Sets the project folder path this will get saved to during a `save(Project, MessageLog, TaskMonitor)` operation.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### Loaded

    public Loaded(T domainObject, String name, String projectFolderPath)
    Creates a new `Loaded` object
    Parameters:
      `domainObject` - The loaded `DomainObject`
      `name` - The name of the loaded `DomainObject`. If a `save(Project, MessageLog, TaskMonitor)` occurs, this will attempted to be used for the resulting `DomainFile`'s name.
      `projectFolderPath` - The project folder path this will get saved to during a `save(Project, MessageLog, TaskMonitor)` operation. If null or empty, the root project folder will be used.

- ## Method Details

  - ### getDomainObject

    public T getDomainObject()
    Gets the loaded `DomainObject`
    Returns:
      The loaded `DomainObject`

  - ### getName

    public String getName()
    Gets the name of the loaded `DomainObject`. If a `save(Project, MessageLog, TaskMonitor)` occurs, this will attempted to be used for the resulting `DomainFile`'s name.
    Returns:
      the name of the loaded `DomainObject`

  - ### getProjectFolderPath

    public String getProjectFolderPath()
    Gets the project folder path this will get saved to during a `save(Project, MessageLog, TaskMonitor)` operation.

    NOTE: The returned path will always end with a "/".

    Returns:
      the project folder path

  - ### setProjectFolderPath

    public void setProjectFolderPath(String projectFolderPath)
    Sets the project folder path this will get saved to during a `save(Project, MessageLog, TaskMonitor)` operation.
    Parameters:
      `projectFolderPath` - The project folder path this will get saved to during a `save(Project, MessageLog, TaskMonitor)` operation. If null or empty, the root project folder will be used.

  - ### release

    public void release(Object consumer)
    Notify the loaded `DomainObject` that the specified consumer is no longer using it. When the last consumer invokes this method, the loaded `DomainObject` will be closed and will become invalid.
    Parameters:
      `consumer` - the consumer

  - ### save

    public DomainFile save(Project project, MessageLog messageLog, TaskMonitor monitor) throws CancelledException, ClosedException, IOException
    Saves the loaded `DomainObject` to the given `Project` at this object's project folder path, using this object's name.

    If a `DomainFile` already exists with the same desired name and project folder path, the desired name will get a counter value appended to it to avoid a naming conflict. Therefore, it should not be assumed that the returned `DomainFile` will have the same name as a call to `getName()`.

    Parameters:
      `project` - The `Project` to save to
      `messageLog` - The log
      `monitor` - A cancelable task monitor
    Returns:
      The `DomainFile` where the save happened
    Throws:
      `CancelledException` - if the operation was cancelled
      `ClosedException` - if the loaded `DomainObject` was already closed
      `IOException` - If there was an IO-related error, an invalid name was specified, or it was already successfully saved and still exists

  - ### getSavedDomainFile

    public DomainFile getSavedDomainFile() throws FileNotFoundException
    Gets the loaded `DomainObject`'s associated `DomainFile` that was `saved`
    Returns:
      The loaded `DomainObject`'s associated saved `DomainFile`, or null if was not saved
    Throws:
      `FileNotFoundException` - If the loaded `DomainObject` was saved but the associated `DomainFile` no longer exists
    See Also:
      - `save(Project, MessageLog, TaskMonitor)`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`