@PublicApi public class FpKit extends Object
Constructor and Description |
---|
FpKit() |
Modifier and Type | Method and Description |
---|---|
static <T,R> List<R> |
flatMap(List<T> list,
com.google.common.base.Function<T,List<R>> mapper)
Allow you flat map a List of type T into a List of type R with less stream syntax
|
static <L,R> Object |
foldToObject(com.atlassian.fugue.Either<L,R> either)
Some times you just need the Either's value as an Object.
|
static <T,S> List<T> |
map(Collection<? extends S> source,
com.google.common.base.Function<S,T> f)
Allows you to map a Collection of S into a List of T with less stream syntax
|
static NoExceptionsCallable<com.atlassian.fugue.Unit> |
runnableToNoExceptionsCallable(Runnable runnable)
Turns a runnable into a callable
|
static <L,R> com.atlassian.fugue.Either<L,R> |
toEither(Optional<R> optional,
com.google.common.base.Supplier<L> leftSupplier)
Allows you to convert JDK8 Optional into a Fugue Either with the optional value in as the right if present.
|
static <T> List<T> |
toList(com.atlassian.fugue.Option<T> option)
Converts an option to a list.
|
static <T> Object |
toObject(T someObject)
Somes times in FP lands you need to turn generic types into the most basic type of all.
|
static <T> com.atlassian.fugue.Option<T> |
toOption(Optional<T> optional)
Allows you to convert JDK8 Optional into a Fugue Option
|
static <T> Optional<T> |
toOptional(com.atlassian.fugue.Option<T> option)
Allows you to convert JDK8 Optional into a Fugue Option
|
public static <T,S> List<T> map(Collection<? extends S> source, com.google.common.base.Function<S,T> f)
source
- the sourcef
- the mapperpublic static <T,R> List<R> flatMap(List<T> list, com.google.common.base.Function<T,List<R>> mapper)
list
- the source list with type Tmapper
- the mapping functionpublic static <T> List<T> toList(com.atlassian.fugue.Option<T> option)
option
- an option of type tpublic static <T> com.atlassian.fugue.Option<T> toOption(Optional<T> optional)
optional
- the optional to convertpublic static <L,R> com.atlassian.fugue.Either<L,R> toEither(Optional<R> optional, com.google.common.base.Supplier<L> leftSupplier)
optional
- the optional to convertleftSupplier
- a supplier of the left sidepublic static <T> Optional<T> toOptional(com.atlassian.fugue.Option<T> option)
option
- the option to convertpublic static <T> Object toObject(T someObject)
someObject
- some objectpublic static <L,R> Object foldToObject(com.atlassian.fugue.Either<L,R> either)
either
- the Either containing objectspublic static NoExceptionsCallable<com.atlassian.fugue.Unit> runnableToNoExceptionsCallable(Runnable runnable)
runnable
- the code to runCopyright © 2019 Atlassian. All rights reserved.