Package ghidra.app.util.opinion
Class LoadResults<T extends DomainObject>
java.lang.Object
ghidra.app.util.opinion.LoadResults<T>
- Type Parameters:
T- The type ofDomainObjects that were loaded
- All Implemented Interfaces:
AutoCloseable,Iterable<Loaded<T>>
public class LoadResults<T extends DomainObject>
extends Object
implements Iterable<Loaded<T>>, AutoCloseable
The result of a
Loader.load(ghidra.app.util.opinion.Loader.ImporterSettings). Provides convenient
access to and operations on the underlying Loaded DomainObjects that got loaded.-
Constructor Summary
ConstructorsChangeConstructorDescriptionLoadResults(Loaded<T> loaded) LoadResults(List<Loaded<T>> loadedList) -
Method Summary
ChangeModifier and TypeMethodDescriptionNEWvoidclose()Closes thisLoadResultsand releases the reference on the object consuming it.NEWDeprecated, for removal: This API element is subject to removal in a future version.NEWgetPrimaryDomainObject(Object consumer) Gets the "primary"DomainObject, whose meaning is defined by eachLoaderimplementation.iterator()voidDeprecated, for removal: This API element is subject to removal in a future version.Useclose()insteadvoidDeprecated, for removal: This API element is subject to removal in a future version.Useclose()insteadvoidreleaseNonPrimary(Object consumer) Deprecated, for removal: This API element is subject to removal in a future version.NEWvoidsave(TaskMonitor monitor) intsize()REMOVEDvoidsave(Project project, Object consumer, MessageLog messageLog, TaskMonitor monitor) RemovedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LoadResults
Creates a newLoadResultsthat contains the given non-emptyListofLoadedDomainObjects. The first entry in theListis assumed to be theprimaryLoadedDomainObject.This object needs to be
closedwhen done with it.- Parameters:
loadedList- AListofLoadedDomainObjects- Throws:
IllegalArgumentException- if the providedListis null or empty
-
LoadResults
Creates a newLoadResultsthat contains the givenLoadedDomainObject. ThisLoadedDomainObjectis assumed to be theprimaryLoadedDomainObject.- Parameters:
loaded- TheLoadedDomainObject
-
-
Method Details
-
getPrimary
- Returns:
- The "primary"
LoadedDomainObject
-
getNonPrimary NEW
- Returns:
- The "non-primary"
LoadedDomainObjects
-
getPrimaryDomainObject NEW
Gets the "primary"DomainObject, whose meaning is defined by eachLoaderimplementation.NOTE: It is the responsibility of the caller to properly
releaseit when done. ThisDomainObject.release(Object)does not replace the requirement toclose()theLoadResultsobject when done.- Parameters:
consumer- A new reference to the object "consuming" the returnedDomainObject, used to ensure the underlyingDomainObjectis only released when every consumer is done with it (seeDomainObject.release(Object)). NOTE: This method adds the given consumer to the returnedDomainObject, requiring an explicitDomainObject.release(Object)to be called on the return value (this entireLoadResultsmust also still beclosed).- Returns:
- The "primary"
DomainObject
-
getPrimaryDomainObject
Deprecated, for removal: This API element is subject to removal in a future version.This class's internalDomainObjects are now cleaned up with theclose()method. If the primaryDomainObjectneeds to be retrieved from this class, instead usegetPrimaryDomainObject(Object)and independently clean up the new reference with a separate call toDomainObject.release(Object).Gets the "primary" loadedDomainObject, whose meaning is defined by eachLoaderimplementation. Unsafe resource management is used. Temporarily exists to provide backwards compatibility.- Returns:
- The "primary"
DomainObject
-
size
public int size()Gets the number ofLoadedDomainObjects in thisLoadResults. The size will always be greater than 0.- Returns:
- The number of
LoadedDomainObjects in thisLoadResults
-
save NEW
- Parameters:
monitor- A cancelable task monitor- Throws:
CancelledException- if the operation was cancelledIOException- If there was a problem saving. A thrown exception may result in only some of theLoadedelements being saved. It is the responsibility of the caller to clean things up appropriately.InvalidNameException- if saving with an invalid name- See Also:
-
release
Deprecated, for removal: This API element is subject to removal in a future version.Useclose()insteadUnsafely notifies all of theLoadedDomainObjects that the specified consumer is no longer using them. Temporarily exists to provide backwards compatibility.- Parameters:
consumer- the consumer
-
release
@Deprecated(since="12.0", forRemoval=true) public void release(Object consumer, Predicate<? super Loaded<T>> filter) Deprecated, for removal: This API element is subject to removal in a future version.Useclose()insteadUnsafely notifies the filteredLoadedDomainObjects that the specified consumer is no longer using them. Temporarily exists to provide backwards compatibility.- Parameters:
consumer- the consumerfilter- a filter to apply to theLoadedDomainObjects prior to the release
-
releaseNonPrimary
Deprecated, for removal: This API element is subject to removal in a future version.Notify the non-primaryLoadedDomainObjects that the specified consumer is no longer using them. When the last consumer invokes this method, the non-primaryLoadedDomainObjects will be closed and will become invalid.- Parameters:
consumer- the consumer
-
close NEW
public void close()Closes thisLoadResultsand releases the reference on the object consuming it.NOTE: Any
DomainObjects obtained viagetPrimaryDomainObject(Object)must still be explicitlyreleasedafter calling this method, since they were obtained with their own consumers.- Specified by:
closein interfaceAutoCloseable
-
iterator
- Specified by:
iteratorin interfaceIterable<T extends DomainObject>
-
DomainObjects are now cleaned up with theclose()method.