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 IdentifiedCollection
s that want to work from an in-memory set of objects.
-
Nested Class Summary
Nested classes/interfaces inherited from interface nz.org.riskscape.engine.IdentifiedCollection
IdentifiedCollection.Base<T extends Identified>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(String identifier, Resource resource, ConstructionCallback<T> builder) Add a potentially lazily constructed identified object to this collection.void
Add a pre-constructed identified object to the collection.void
Same asIdentifiedCollection.add(nz.org.riskscape.engine.Identified)
but with specified source.void
addAll
(@NonNull Collection<T> identifieds) Add all of the given objects to this collection, returning a list of any that were replacedvoid
addAll
(Collection<T> identifieds, Resource source) void
clear()
Remove everything from the collectionboolean
containsKey
(@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 aNoSuchObjectException
or aFailedObjectException
would have, but as part of a ResultOrProblems.Alternative to get that returns the result wrapped in anOptional
and aResultOrProblems
instead of throwingIdentifiedException
s.getSimilarIds
(String candidate) Find possible matches for a failed id lookup.boolean
isEmpty()
boolean
Removes an object from the collectionprotected void
removeAll
(@NonNull Collection<T> items) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:IdentifiedCollection
Add a potentially lazily constructed identified object to this collection.
- Specified by:
add
in interfaceIdentifiedCollection<T extends Identified>
- Parameters:
identifier
- uniquely identifies the to be constructed objectresource
- a Resource that is linked to the original object - may beResource.UNKNOWN
builder
- a callback that will return the object - expect that theIdentifiedCollection
will cache the result of this call
-
remove
Description copied from interface:IdentifiedCollection
Removes an object from the collection
- Specified by:
remove
in interfaceIdentifiedCollection<T extends Identified>
- Returns:
- true if there was something in the collection with this id, failed or otherwise
-
add
Description copied from interface:IdentifiedCollection
Add a pre-constructed identified object to the collection.
- Specified by:
add
in interfaceIdentifiedCollection<T extends Identified>
- Parameters:
identified
- object to add
-
add
Description copied from interface:IdentifiedCollection
Same as
IdentifiedCollection.add(nz.org.riskscape.engine.Identified)
but with specified source.- Specified by:
add
in interfaceIdentifiedCollection<T extends Identified>
-
addAll
Description copied from interface:IdentifiedCollection
Add all of the given objects to this collection, returning a list of any that were replaced
- Specified by:
addAll
in interfaceIdentifiedCollection<T extends Identified>
-
addAll
Description copied from interface:IdentifiedCollection
- Specified by:
addAll
in interfaceIdentifiedCollection<T extends Identified>
- Throws:
ObjectAlreadyExistsException
-
getAll
- Specified by:
getAll
in 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:
getAllProblems
in interfaceIdentifiedCollection<T extends Identified>
- Returns:
- A list of all the problems associated with any failed items in this collection.
-
getReferences
- Specified by:
getReferences
in interfaceIdentifiedCollection<T extends Identified>
- Returns:
- all items in the collection ordered by id
-
get
Description copied from interface:IdentifiedCollection
Get an object from the collection that has the given id.
- Specified by:
get
in 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:IdentifiedCollection
ResultOrProblems returning alternative to get, which will return the same problems that a
NoSuchObjectException
or aFailedObjectException
would have, but as part of a ResultOrProblems. Also adds any warnings that were encountered in to the result.- Specified by:
getOr
in interfaceIdentifiedCollection<T extends Identified>
-
determineCollectionClass
-
getResult
Description copied from interface:IdentifiedCollection
Alternative to get that returns the result wrapped in an
Optional
and aResultOrProblems
instead of throwingIdentifiedException
s.- Specified by:
getResult
in interfaceIdentifiedCollection<T extends Identified>
-
containsKey
- Specified by:
containsKey
in interfaceIdentifiedCollection<T extends Identified>
- Returns:
- true if collection contains an item with matching id
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceIdentifiedCollection<T extends Identified>
- Returns:
- true of this collection contains no entries, failed or otherwise
-
clear
public void clear()Description copied from interface:IdentifiedCollection
Remove everything from the collection
- Specified by:
clear
in interfaceIdentifiedCollection<T extends Identified>
-
removeAll
-
getSimilarIds
Description copied from interface:IdentifiedCollection
Find possible matches for a failed id lookup.
- Specified by:
getSimilarIds
in 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:
getCollectionClass
in 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.Base
do not declare a type for T parameters have been set.
-