Class PrioritizedComponents<T>

  • Type Parameters:
    T - The component type.

    public final class PrioritizedComponents<T>
    extends java.lang.Object
    Helps to sort pluggable components by their priority.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(T component, float priority)  
      java.util.List<PrioritizedComponent<T>> getAll()  
      java.util.List<PrioritizedComponent<T>> getEnabled()  
      boolean isEmpty()  
      void list​(java.lang.StringBuilder buffer)  
      static <C> PrioritizedComponents<C> reuseOrCreate​(org.eclipse.aether.RepositorySystemSession session, java.lang.Class<C> discriminator, java.util.Map<java.lang.String,​C> components, java.util.function.Function<C,​java.lang.Float> priorityFunction)
      Reuses or creates and caches (if session is equipped with cache, and it does not contain it yet) prioritized components under certain key into session cache.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • reuseOrCreate

        public static <C> PrioritizedComponents<C> reuseOrCreate​(org.eclipse.aether.RepositorySystemSession session,
                                                                 java.lang.Class<C> discriminator,
                                                                 java.util.Map<java.lang.String,​C> components,
                                                                 java.util.function.Function<C,​java.lang.Float> priorityFunction)
        Reuses or creates and caches (if session is equipped with cache, and it does not contain it yet) prioritized components under certain key into session cache. Same session is used to configure prioritized components, so priority sorted components during session are immutable and reusable (if components component map is unchanged).

        The components are expected to be Sisu injected Map-like dynamic component maps. There is a simple "change detection" in place, as injected maps are dynamic, they are atomically expanded or contracted as components are dynamically discovered or unloaded.

        Since:
        2.0.0
      • add

        public void add​(T component,
                        float priority)
      • isEmpty

        public boolean isEmpty()
      • list

        public void list​(java.lang.StringBuilder buffer)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object