Class IdStore<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    ExtensionPoint
    Direct Known Subclasses:
    PersistenceRootIdStore, RunIdStore, UserIdStore

    public abstract class IdStore<T>
    extends Object
    implements ExtensionPoint
    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.
    • Constructor Detail

      • IdStore

        public IdStore​(Class<T> forType)
    • Method Detail

      • make

        public abstract void make​(T object)
        Creates an unique id for the given object. Subsequent calls are idempotent.
        Parameters:
        object - the object to make the id for.
      • get

        @Nullable
        public abstract String get​(T object)
        Get the id for this given object.
        Parameters:
        object - the object.
        Returns:
        the id or null if none assigned.
      • supports

        public boolean supports​(Class clazz)
      • forClass

        @Nullable
        public static <C> IdStore<C> forClass​(Class<C> clazz)
        Retrieve an IdStore 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.
      • fileName

        @Nonnull
        public static String fileName()
        Returns the generic filename that a store should use for storing the unique id.
        Returns:
        the generic filename.
        Since:
        2.1.0
      • generateUniqueID

        protected static String 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.