public class

ModuleDescriptorUtils

extends Object
java.lang.Object
   ↳ com.atlassian.stash.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>> Iterable<T> toModules(Iterable<M> descriptors)
Convert an Iterable of ModuleDescriptor into an Iterable of T, where T is the type returned by getModule().
static <T, M extends BaseWeightedModuleDescriptor<T>> Iterable<T> toSortedModules(Iterable<M> descriptors)
Convert an Iterable of BaseWeightedModuleDescriptor into an Iterable 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 Iterable<T> toModules (Iterable<M> descriptors)

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

Parameters
descriptors the module descriptors to convert.
Returns
  • an iterable of modules, sourced from the descriptors.

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

Convert an Iterable of BaseWeightedModuleDescriptor into an Iterable 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 iterable of modules, sourced from the descriptors and sorted by the descriptor's weight.