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 anIterable
ofModuleDescriptor
into aStream
ofModuleDescriptorUtils
, where T is the type returned byModuleDescriptor.getModule()
.static <T,
M extends com.atlassian.plugin.ModuleDescriptor<T>>
Stream<T>Convert aStream
ofModuleDescriptor
into aStream
ofModuleDescriptorUtils
, where T is the type returned byModuleDescriptor.getModule()
.static <T,
M extends BaseWeightedModuleDescriptor<T>>
Stream<T>toSortedModules
(Collection<M> descriptors) Convert aCollection
ofBaseWeightedModuleDescriptor
into aStream
ofModuleDescriptorUtils
(sorted byBaseWeightedModuleDescriptor's
weight), where T is the type returned byModuleDescriptor.getModule()
.static <T,
M extends BaseWeightedModuleDescriptor<T>>
Stream<T>toSortedModules
(Stream<M> descriptors) Convert aStream
ofBaseWeightedModuleDescriptor
into aStream
ofModuleDescriptorUtils
(sorted byBaseWeightedModuleDescriptor's
weight), where T is the type returned byModuleDescriptor.getModule()
.
-
Method Details
-
toModule
- Type Parameters:
T
- type of moduleM
- type of module descriptor- Returns:
- a generic
Function
for picking the result ofModuleDescriptor.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 anIterable
ofModuleDescriptor
into aStream
ofModuleDescriptorUtils
, 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 aStream
ofModuleDescriptor
into aStream
ofModuleDescriptorUtils
, 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 aCollection
ofBaseWeightedModuleDescriptor
into aStream
ofModuleDescriptorUtils
(sorted byBaseWeightedModuleDescriptor's
weight), 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 aStream
ofBaseWeightedModuleDescriptor
into aStream
ofModuleDescriptorUtils
(sorted byBaseWeightedModuleDescriptor's
weight), 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.
-