本文整理了Java中io.vavr.control.Option.flatMap()
方法的一些代码示例,展示了Option.flatMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.flatMap()
方法的具体详情如下:
包路径:io.vavr.control.Option
类名称:Option
方法名:flatMap
[英]Maps the value to a new Option if this is a Some, otherwise returns None.
[中]如果是Some,则将值映射到新选项,否则返回None。
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.flatMap(t5 ->
ts6.flatMap(t6 ->
ts7.flatMap(t7 ->
ts8.map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)))))))));
}
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.flatMap(t5 ->
ts6.flatMap(t6 ->
ts7.map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7))))))));
}
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.flatMap(t5 ->
ts6.map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)))))));
}
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.map(t5 -> f.apply(t1, t2, t3, t4, t5))))));
}
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.map(t4 -> f.apply(t1, t2, t3, t4)))));
}
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(BiFunction<? super T1, ? super T2, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.map(t2 -> f.apply(t1, t2)));
}
代码示例来源:origin: vavr-io/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function3<? super T1, ? super T2, ? super T3, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.map(t3 -> f.apply(t1, t2, t3))));
}
代码示例来源:origin: jdbi/jdbi
private Option<Collector<?, ?, ?>> resolveDefaultCollector(Class<?> erasedType) {
return defaultImplementations.get(erasedType).flatMap(collectors::get);
}
代码示例来源:origin: vavr-io/vavr
/**
* Collects value that is in the domain of the given {@code partialFunction} by mapping the value to type {@code R}.
*
* <pre>{@code
* partialFunction.isDefinedAt(value)
* }</pre>
*
* If the element makes it through that filter, the mapped instance is wrapped in {@code Option}
*
* <pre>{@code
* R newValue = partialFunction.apply(value)
* }</pre>
*
*
* @param partialFunction A function that is not necessarily defined on value of this option.
* @param <R> The new value type
* @return A new {@code Option} instance containing value of type {@code R}
* @throws NullPointerException if {@code partialFunction} is null
*/
default <R> Option<R> collect(PartialFunction<? super T, ? extends R> partialFunction) {
Objects.requireNonNull(partialFunction, "partialFunction is null");
return flatMap(partialFunction.lift()::apply);
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.flatMap(t5 ->
ts6.flatMap(t6 ->
ts7.flatMap(t7 ->
ts8.map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)))))))));
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.flatMap(t5 ->
ts6.flatMap(t6 ->
ts7.map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7))))))));
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.map(t5 -> f.apply(t1, t2, t3, t4, t5))))));
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.flatMap(t4 ->
ts5.flatMap(t5 ->
ts6.map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)))))));
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.flatMap(t3 ->
ts4.map(t4 -> f.apply(t1, t2, t3, t4)))));
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(BiFunction<? super T1, ? super T2, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.map(t2 -> f.apply(t1, t2)));
}
代码示例来源:origin: io.vavr/vavr
/**
* Yields a result for elements of the cross product of the underlying Options.
*
* @param f a function that maps an element of the cross product to a result
* @param <R> type of the resulting {@code Option} elements
* @return an {@code Option} of mapped results
*/
public <R> Option<R> yield(Function3<? super T1, ? super T2, ? super T3, ? extends R> f) {
Objects.requireNonNull(f, "f is null");
return
ts1.flatMap(t1 ->
ts2.flatMap(t2 ->
ts3.map(t3 -> f.apply(t1, t2, t3))));
}
代码示例来源:origin: io.vavr/vavr
/**
* Collects value that is in the domain of the given {@code partialFunction} by mapping the value to type {@code R}.
*
* <pre>{@code
* partialFunction.isDefinedAt(value)
* }</pre>
*
* If the element makes it through that filter, the mapped instance is wrapped in {@code Option}
*
* <pre>{@code
* R newValue = partialFunction.apply(value)
* }</pre>
*
*
* @param partialFunction A function that is not necessarily defined on value of this option.
* @param <R> The new value type
* @return A new {@code Option} instance containing value of type {@code R}
* @throws NullPointerException if {@code partialFunction} is null
*/
default <R> Option<R> collect(PartialFunction<? super T, ? extends R> partialFunction) {
Objects.requireNonNull(partialFunction, "partialFunction is null");
return flatMap(partialFunction.lift()::apply);
}
代码示例来源:origin: com.mercateo.eventstore/client-common
private Option<EventStore> createEventStore(EventStoreName eventStoreName) {
return eventStoreProperties
.get(eventStoreName)
.map(factory::createEventStore)
.peek(store -> store.peekLeft(error -> log.error("could not create event store client with name {}",
eventStoreName)))
.flatMap(Either::toOption);
}
}
代码示例来源:origin: org.assertj/assertj-vavr
/**
* Call {@link Option#flatMap(Function) flatMap} on the {@code Option} under test, assertions chained afterwards are performed on the {@code Option} resulting from the flatMap call.
*
* @param <U> the type of a value contained in {@link Option}.
* @param mapper the {@link Function} to use in the {@link Option#flatMap(Function) flatMap} operation.
* @return a new {@link org.assertj.vavr.api.AbstractOptionAssert} for assertions chaining on the flatMap of the Option.
* @throws AssertionError if the actual {@link Option} is null.
*/
@CheckReturnValue
public <U> AbstractOptionAssert<?, U> flatMap(Function<? super VALUE, Option<U>> mapper) {
isNotNull();
return VavrAssertions.assertThat(actual.flatMap(mapper));
}
内容来源于网络,如有侵权,请联系作者删除!