Package org.jenkinsci.plugins.uniqueid
Class IdStore<T>
java.lang.Object
org.jenkinsci.plugins.uniqueid.IdStore<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
PersistenceRootIdStore
,RunIdStore
,UserIdStore
An abstraction to persistently store and retrieve unique id's
for various Jenkins model objects.
These keys are guaranteed to be unique with a Jenkins
and immutable across the lifetime of the given object.
Implementations should not store the ID inside any specific item configuration as it is
common for users top copy items either through the UI or manually and this will cause the
IDs to become non-unique.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
fileName()
Returns the generic filename that a store should use for storing the unique id.static <C> IdStore<C>
Retrieve anIdStore
for the given type.protected static String
Generates a new unique ID.abstract String
Get the id for this given object.static String
Convenience method which retrieves the id for the given object.abstract void
Creates an unique id for the given object.static void
Convenience method which makes the id for the given object.boolean
-
Constructor Details
-
IdStore
-
-
Method Details
-
make
Creates an unique id for the given object. Subsequent calls are idempotent.- Parameters:
object
- the object to make the id for.
-
get
Get the id for this given object.- Parameters:
object
- the object.- Returns:
- the id or
null
if none assigned.
-
supports
-
forClass
Retrieve anIdStore
for the given type.- Type Parameters:
C
- the type of object.- Parameters:
clazz
- the type of object.- Returns:
- the store which supports the type, or
null
if none.
-
makeId
Convenience method which makes the id for the given object.- Throws:
IllegalArgumentException
- if the type is not supported.
-
getId
Convenience method which retrieves the id for the given object.- Throws:
IllegalArgumentException
- if the type is not supported.
-
fileName
Returns the generic filename that a store should use for storing the unique id.- Returns:
- the generic filename.
- Since:
- 2.1.0
-
generateUniqueID
Generates a new unique ID. Subclasses do not need to use this to create unique IDs and are free to create IDs by other methods.- Returns:
- a string that should be unique against all jenkins instances.
-