Class IdentifiedCollection.Base<T extends Identified>
- All Implemented Interfaces:
IdentifiedCollection<T>
- Direct Known Subclasses:
ExtensionPoints,PipelineSteps,SecretBuilders,Secrets,TypeRegistry,TypeSet
- Enclosing interface:
- IdentifiedCollection<T extends Identified>
Convenience class for any IdentifiedCollections that want to work from an in-memory set of objects.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface nz.org.riskscape.engine.IdentifiedCollection
IdentifiedCollection.Base<T extends Identified> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String identifier, Resource resource, ConstructionCallback<T> builder) Add a potentially lazily constructed identified object to this collection.voidAdd a pre-constructed identified object to the collection.voidSame asIdentifiedCollection.add(nz.org.riskscape.engine.Identified)but with specified source.voidaddAll(@NonNull Collection<T> identifieds) Add all of the given objects to this collection, returning a list of any that were replacedvoidaddAll(Collection<T> identifieds, Resource source) voidclear()Remove everything from the collectionbooleancontainsKey(@NonNull String id) get(@NonNull String id, ProblemSink problemSink) Get an object from the collection that has the given id.getAll()ResultOrProblems returning alternative to get, which will return the same problems that aNoSuchObjectExceptionor aFailedObjectExceptionwould have, but as part of a ResultOrProblems.Alternative to get that returns the result wrapped in anOptionaland aResultOrProblemsinstead of throwingIdentifiedExceptions.getSimilarIds(String candidate) Find possible matches for a failed id lookup.booleanisEmpty()booleanRemoves an object from the collectionprotected voidremoveAll(@NonNull Collection<T> items) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nz.org.riskscape.engine.IdentifiedCollection
get
-
Field Details
-
results
-
-
Constructor Details
-
Base
public Base() -
Base
-
-
Method Details
-
add
Description copied from interface:IdentifiedCollectionAdd a potentially lazily constructed identified object to this collection.
- Specified by:
addin interfaceIdentifiedCollection<T extends Identified>- Parameters:
identifier- uniquely identifies the to be constructed objectresource- a Resource that is linked to the original object - may beResource.UNKNOWNbuilder- a callback that will return the object - expect that theIdentifiedCollectionwill cache the result of this call
-
remove
Description copied from interface:IdentifiedCollectionRemoves an object from the collection
- Specified by:
removein interfaceIdentifiedCollection<T extends Identified>- Returns:
- true if there was something in the collection with this id, failed or otherwise
-
add
Description copied from interface:IdentifiedCollectionAdd a pre-constructed identified object to the collection.
- Specified by:
addin interfaceIdentifiedCollection<T extends Identified>- Parameters:
identified- object to add
-
add
Description copied from interface:IdentifiedCollectionSame as
IdentifiedCollection.add(nz.org.riskscape.engine.Identified)but with specified source.- Specified by:
addin interfaceIdentifiedCollection<T extends Identified>
-
addAll
Description copied from interface:IdentifiedCollectionAdd all of the given objects to this collection, returning a list of any that were replaced
- Specified by:
addAllin interfaceIdentifiedCollection<T extends Identified>
-
addAll
Description copied from interface:IdentifiedCollection- Specified by:
addAllin interfaceIdentifiedCollection<T extends Identified>- Throws:
ObjectAlreadyExistsException
-
getAll
- Specified by:
getAllin interfaceIdentifiedCollection<T extends Identified>- Returns:
- all items in the collection ordered by id, excluding failed things Note that any problems will be ignored.
-
getAllProblems
- Specified by:
getAllProblemsin interfaceIdentifiedCollection<T extends Identified>- Returns:
- A list of all the problems associated with any failed items in this collection.
-
getReferences
- Specified by:
getReferencesin interfaceIdentifiedCollection<T extends Identified>- Returns:
- all items in the collection ordered by id
-
get
Description copied from interface:IdentifiedCollectionGet an object from the collection that has the given id.
- Specified by:
getin interfaceIdentifiedCollection<T extends Identified>- Parameters:
id- of item to get.problemSink- a place for any warnings or info problems to be sent during lookup/construction- Returns:
- item
-
getOr
Description copied from interface:IdentifiedCollectionResultOrProblems returning alternative to get, which will return the same problems that a
NoSuchObjectExceptionor aFailedObjectExceptionwould have, but as part of a ResultOrProblems. Also adds any warnings that were encountered in to the result.- Specified by:
getOrin interfaceIdentifiedCollection<T extends Identified>
-
determineCollectionClass
-
getResult
Description copied from interface:IdentifiedCollectionAlternative to get that returns the result wrapped in an
Optionaland aResultOrProblemsinstead of throwingIdentifiedExceptions.- Specified by:
getResultin interfaceIdentifiedCollection<T extends Identified>
-
containsKey
- Specified by:
containsKeyin interfaceIdentifiedCollection<T extends Identified>- Returns:
- true if collection contains an item with matching id
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceIdentifiedCollection<T extends Identified>- Returns:
- true of this collection contains no entries, failed or otherwise
-
clear
public void clear()Description copied from interface:IdentifiedCollectionRemove everything from the collection
- Specified by:
clearin interfaceIdentifiedCollection<T extends Identified>
-
removeAll
-
getSimilarIds
Description copied from interface:IdentifiedCollectionFind possible matches for a failed id lookup.
- Specified by:
getSimilarIdsin interfaceIdentifiedCollection<T extends Identified>- Parameters:
candidate- the id that doesn't exist in this collection- Returns:
- a List of ids that might be what the user was looking for
-
getCollectionClass
- Specified by:
getCollectionClassin interfaceIdentifiedCollection<T extends Identified>- Returns:
- the class from this collections type signature. E.g. if this is
Foo extends IdentifiedCollection<Bar>then getCollectionClass() will return a class instance for Bar.This method will fail if sub classes of
IdentifiedCollection.Basedo not declare a type for T parameters have been set.
-