Package com.atlassian.bitbucket.util
Class ModuleDescriptorUtils
java.lang.Object
com.atlassian.bitbucket.util.ModuleDescriptorUtils
Utility methods for working with plugin
ModuleDescriptors.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,M extends com.atlassian.plugin.ModuleDescriptor<T>>
Function<M,T> toModule()static <T,M extends com.atlassian.plugin.ModuleDescriptor<T>>
Stream<T>toModules(Collection<M> descriptors) Convert anIterableofModuleDescriptorinto aStreamofModuleDescriptorUtils, where T is the type returned byModuleDescriptor.getModule().static <T,M extends com.atlassian.plugin.ModuleDescriptor<T>>
Stream<T>Convert aStreamofModuleDescriptorinto aStreamofModuleDescriptorUtils, where T is the type returned byModuleDescriptor.getModule().static <T,M extends BaseWeightedModuleDescriptor<T>>
Stream<T>toSortedModules(Collection<M> descriptors) Convert aCollectionofBaseWeightedModuleDescriptorinto aStreamofModuleDescriptorUtils(sorted byBaseWeightedModuleDescriptor'sweight), where T is the type returned byModuleDescriptor.getModule().static <T,M extends BaseWeightedModuleDescriptor<T>>
Stream<T>toSortedModules(Stream<M> descriptors) Convert aStreamofBaseWeightedModuleDescriptorinto aStreamofModuleDescriptorUtils(sorted byBaseWeightedModuleDescriptor'sweight), where T is the type returned byModuleDescriptor.getModule().
-
Method Details
-
toModule
- Type Parameters:
T- type of moduleM- type of module descriptor- Returns:
- a generic
Functionfor picking the result ofModuleDescriptor.getModule()from a descriptor.The cast is safe as a
ModuleDescriptorcan 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 anIterableofModuleDescriptorinto aStreamofModuleDescriptorUtils, where T is the type returned byModuleDescriptor.getModule().- Type Parameters:
T- the type of module returned by the descriptorsM- 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 aStreamofModuleDescriptorinto aStreamofModuleDescriptorUtils, where T is the type returned byModuleDescriptor.getModule().- Type Parameters:
T- the type of module returned by the descriptorsM- 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 aCollectionofBaseWeightedModuleDescriptorinto aStreamofModuleDescriptorUtils(sorted byBaseWeightedModuleDescriptor'sweight), where T is the type returned byModuleDescriptor.getModule().- Type Parameters:
T- the type of module returned by the descriptorsM- 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 aStreamofBaseWeightedModuleDescriptorinto aStreamofModuleDescriptorUtils(sorted byBaseWeightedModuleDescriptor'sweight), where T is the type returned byModuleDescriptor.getModule().- Type Parameters:
T- the type of module returned by the descriptorsM- 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.
-