public class

ModuleDescriptorUtils

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

Class Overview

Utility methods for working with plugin ModuleDescriptor ModuleDescriptors.

Summary

Public Methods
static <T, M extends ModuleDescriptor<T>> Function<M, T> toModule()
static <T, M extends ModuleDescriptor<T>> Stream<T> toModules(Collection<M> descriptors)
Convert an Iterable of ModuleDescriptor into a Stream of T, where T is the type returned by getModule().
static <T, M extends ModuleDescriptor<T>> Stream<T> toModules(Stream<M> descriptors)
Convert a Stream of ModuleDescriptor into a Stream of T, where T is the type returned by getModule().
static <T, M extends BaseWeightedModuleDescriptor<T>> Stream<T> toSortedModules(Collection<M> descriptors)
Convert a Collection of BaseWeightedModuleDescriptor into a Stream of T (sorted by BaseWeightedModuleDescriptor's weight), where T is the type returned by getModule().
static <T, M extends BaseWeightedModuleDescriptor<T>> Stream<T> toSortedModules(Stream<M> descriptors)
Convert a Stream of BaseWeightedModuleDescriptor into a Stream of T (sorted by BaseWeightedModuleDescriptor's weight), where T is the type returned by getModule().
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Function<M, T> toModule ()

Returns
  • a generic Function for picking the result of getModule() from a descriptor.

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

public static Stream<T> toModules (Collection<M> descriptors)

Convert an Iterable of ModuleDescriptor into a Stream of T, where T is the type returned by getModule().

Parameters
descriptors the module descriptors to convert.
Returns
  • a Stream of modules, sourced from the descriptors.

public static Stream<T> toModules (Stream<M> descriptors)

Convert a Stream of ModuleDescriptor into a Stream of T, where T is the type returned by getModule().

Parameters
descriptors the module descriptors to convert.
Returns
  • a Stream of modules, sourced from the descriptors.

public static Stream<T> toSortedModules (Collection<M> descriptors)

Convert a Collection of BaseWeightedModuleDescriptor into a Stream of T (sorted by BaseWeightedModuleDescriptor's weight), where T is the type returned by getModule().

Parameters
descriptors the weighted module descriptors to convert.
Returns
  • a Stream of modules, sourced from the descriptors and sorted by the descriptor's weight.

public static Stream<T> toSortedModules (Stream<M> descriptors)

Convert a Stream of BaseWeightedModuleDescriptor into a Stream of T (sorted by BaseWeightedModuleDescriptor's weight), where T is the type returned by getModule().

Parameters
descriptors the weighted module descriptors to convert.
Returns
  • a Stream of modules, sourced from the descriptors and sorted by the descriptor's weight.