Class ModuleDescriptorUtils

java.lang.Object
com.atlassian.bitbucket.util.ModuleDescriptorUtils

public class ModuleDescriptorUtils extends Object
Utility methods for working with plugin ModuleDescriptors.
  • Method Details

    • toModule

      public static <T, M extends com.atlassian.plugin.ModuleDescriptor<T>> Function<M,T> toModule()
      Type Parameters:
      T - type of module
      M - type of module descriptor
      Returns:
      a generic Function for picking the result of ModuleDescriptor.getModule() from a descriptor.

      The cast is safe as a ModuleDescriptor can only ever return a module of it's generic type.

    • toModules

      public static <T, M extends com.atlassian.plugin.ModuleDescriptor<T>> Stream<T> toModules(Collection<M> descriptors)
      Convert an Iterable of ModuleDescriptor into a Stream of ModuleDescriptorUtils, where T is the type returned by ModuleDescriptor.getModule().
      Type Parameters:
      T - the type of module returned by the descriptors
      M - the module descriptors' type
      Parameters:
      descriptors - the module descriptors to convert.
      Returns:
      a Stream of modules, sourced from the descriptors.
    • toModules

      public static <T, M extends com.atlassian.plugin.ModuleDescriptor<T>> Stream<T> toModules(Stream<M> descriptors)
      Convert a Stream of ModuleDescriptor into a Stream of ModuleDescriptorUtils, where T is the type returned by ModuleDescriptor.getModule().
      Type Parameters:
      T - the type of module returned by the descriptors
      M - the module descriptors' type
      Parameters:
      descriptors - the module descriptors to convert.
      Returns:
      a Stream of modules, sourced from the descriptors.
    • toSortedModules

      public static <T, M extends BaseWeightedModuleDescriptor<T>> Stream<T> toSortedModules(Collection<M> descriptors)
      Convert a Collection of BaseWeightedModuleDescriptor into a Stream of ModuleDescriptorUtils (sorted by BaseWeightedModuleDescriptor's weight), where T is the type returned by ModuleDescriptor.getModule().
      Type Parameters:
      T - the type of module returned by the descriptors
      M - the weighted module descriptors' type
      Parameters:
      descriptors - the weighted module descriptors to convert.
      Returns:
      a Stream of modules, sourced from the descriptors and sorted by the descriptor's weight.
    • toSortedModules

      public static <T, M extends BaseWeightedModuleDescriptor<T>> Stream<T> toSortedModules(Stream<M> descriptors)
      Convert a Stream of BaseWeightedModuleDescriptor into a Stream of ModuleDescriptorUtils (sorted by BaseWeightedModuleDescriptor's weight), where T is the type returned by ModuleDescriptor.getModule().
      Type Parameters:
      T - the type of module returned by the descriptors
      M - the weighted module descriptors' type
      Parameters:
      descriptors - the weighted module descriptors to convert.
      Returns:
      a Stream of modules, sourced from the descriptors and sorted by the descriptor's weight.