本文整理汇总了Java中reactor.util.function.Tuples类的典型用法代码示例。如果您正苦于以下问题:Java Tuples类的具体用法?Java Tuples怎么用?Java Tuples使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tuples类属于reactor.util.function包,在下文中一共展示了Tuples类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: link
import reactor.util.function.Tuples; //导入依赖的package包/类
public String link(String module, URL api, String email, String password) {
CloudFoundryClient client = appDeployerFactory.getCloudFoundryClient(email, password, api);
return PaginationUtils.requestClientV2Resources(page -> client.applicationsV2()
.list(ListApplicationsRequest.builder()
.name(module)
.build()))
.flatMap(applicationResource -> client.spaces()
.get(GetSpaceRequest.builder()
.spaceId(applicationResource.getEntity().getSpaceId())
.build())
.map(spaceResponse -> Tuples.of(spaceResponse, applicationResource)))
.map(function((spaceResponse, applicationResource) ->
"/organizations/" + spaceResponse.getEntity().getOrganizationId() +
"/spaces/" + spaceResponse.getMetadata().getId() +
"/applications/" + applicationResource.getMetadata().getId()))
.blockFirst();
}
开发者ID:spring-cloud,项目名称:spring-cloud-spinnaker,代码行数:20,代码来源:ModuleService.java
示例2: getRuleDescription
import reactor.util.function.Tuples; //导入依赖的package包/类
private static Mono<String> getRuleDescription(CloudFoundryClient cloudFoundryClient, String bindingId, String serviceInstanceId) {
return getServiceInstance(cloudFoundryClient, serviceInstanceId)
.then(serviceInstance -> Mono.when(
Mono.just(bindingId),
Mono.just(serviceInstance),
getPlan(cloudFoundryClient, serviceInstance.getServicePlanId()).map(ServicePlanEntity::getServiceId)
))
.then(function((serviceBindingId, serviceInstance, serviceId) -> getService(cloudFoundryClient, serviceId)
.map(ServiceEntity::getServiceBrokerId)
.map(serviceBrokerId -> Tuples.of(serviceBindingId, serviceInstance, serviceBrokerId))))
.then(function((serviceBindingId, serviceInstance, serviceBrokerId) -> getServiceBrokerName(cloudFoundryClient, serviceBrokerId)
.map(serviceBrokerName -> Tuples.of(serviceBindingId, serviceInstance, serviceBrokerName))))
.map(function((servicebindingId, serviceInstance, serviceBrokerName) -> ImmutableRuleDescription.builder()
.servicebindingId(servicebindingId)
.serviceInstanceName(serviceInstance.getName())
.serviceBrokerName(serviceBrokerName).build()
.value()));
}
开发者ID:orange-cloudfoundry,项目名称:sec-group-broker-filter,代码行数:19,代码来源:CreateSecurityGroup.java
示例3: createOrAppend
import reactor.util.function.Tuples; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static <T> ParallelFlux<T> createOrAppend(ParallelFlux<T> source, String tagName, String tagValue) {
Objects.requireNonNull(tagName, "tagName");
Objects.requireNonNull(tagValue, "tagValue");
Set<Tuple2<String, String>> tags = Collections.singleton(Tuples.of(tagName, tagValue));
if (source instanceof ParallelFluxName) {
ParallelFluxName<T> s = (ParallelFluxName<T>) source;
if(s.tags != null) {
tags = new HashSet<>(tags);
tags.addAll(s.tags);
}
return new ParallelFluxName<>(s.source, s.name, tags);
}
return new ParallelFluxName<>(source, null, tags);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:ParallelFluxName.java
示例4: doPut
import reactor.util.function.Tuples; //导入依赖的package包/类
Mono<Tuple2<Integer, String>> doPut(String url, Mono<String> data) {
Mono<Tuple2<String, Optional<Object>>> dataAndContext =
data.zipWith(Mono.subscriberContext()
.map(c -> c.getOrEmpty(HTTP_CORRELATION_ID)));
return dataAndContext
.<String>handle((dac, sink) -> {
if (dac.getT2().isPresent()) {
sink.next("PUT <" + dac.getT1() + "> sent to " + url + " with header X-Correlation-ID = " + dac.getT2().get());
}
else {
sink.next("PUT <" + dac.getT1() + "> sent to " + url);
}
sink.complete();
})
.map(msg -> Tuples.of(200, msg));
}
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:GuideTests.java
示例5: scanOperator
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
Flux<Integer> source = Flux.range(1, 4).map(i -> i);
FluxName<Integer> test = new FluxName<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(-1);
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:20,代码来源:FluxNameTest.java
示例6: defaultFused
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void defaultFused() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.index()
)
.expectFusion()
.expectNext(Tuples.of(0L, 0))
.expectNextMatches(t -> t.getT1() == t.getT2().longValue())
.thenConsumeWhile(t -> t.getT1() == t.getT2().longValue(),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:FluxIndexedFuseableTest.java
示例7: defaultFusedBackpressured
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void defaultFusedBackpressured() {
AtomicLong counter = new AtomicLong(4);
StepVerifier.create(
Flux.range(0, 1000)
.index()
, 0)
.expectSubscription()
.expectNoEvent(Duration.ofMillis(100))
.thenRequest(1)
.expectNext(Tuples.of(0L, 0))
.expectNoEvent(Duration.ofMillis(100))
.thenRequest(3)
.expectNext(Tuples.of(1L, 1))
.expectNext(Tuples.of(2L, 2))
.expectNext(Tuples.of(3L, 3))
.thenRequest(Long.MAX_VALUE)
.thenConsumeWhile(t -> t.getT1() == t.getT2().longValue(),
it -> counter.incrementAndGet())
.verifyComplete();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:25,代码来源:FluxIndexedFuseableTest.java
示例8: defaultFusedConditional
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void defaultFusedConditional() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.index()
.filter(it -> true)
)
.expectFusion()
.expectNext(Tuples.of(0L, 0))
.expectNextMatches(t -> t.getT1() == t.getT2().longValue())
.thenConsumeWhile(t -> t.getT1() == t.getT2().longValue(),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:19,代码来源:FluxIndexedFuseableTest.java
示例9: customFused
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void customFused() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.index((i, v) -> Tuples.of("#" + (i + 1), v))
)
.expectFusion()
.expectNext(Tuples.of("#1", 0))
.expectNextMatches(t -> t.getT1().equals("#" + (t.getT2() + 1)))
.thenConsumeWhile(t -> t.getT1().equals("#" + (t.getT2() + 1)),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:18,代码来源:FluxIndexedFuseableTest.java
示例10: customFusedBackpressured
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void customFusedBackpressured() {
AtomicLong counter = new AtomicLong(4);
StepVerifier.create(
Flux.range(0, 1000)
.index((i, v) -> Tuples.of("#" + (i + 1), v))
, 0)
.expectSubscription()
.expectNoEvent(Duration.ofMillis(100))
.thenRequest(1)
.expectNext(Tuples.of("#1", 0))
.expectNoEvent(Duration.ofMillis(100))
.thenRequest(3)
.expectNext(Tuples.of("#2", 1))
.expectNext(Tuples.of("#3", 2))
.expectNext(Tuples.of("#4", 3))
.thenRequest(Long.MAX_VALUE)
.thenConsumeWhile(t -> t.getT1().equals("#" + (t.getT2() + 1)),
it -> counter.incrementAndGet())
.verifyComplete();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:25,代码来源:FluxIndexedFuseableTest.java
示例11: customFusedConditional
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void customFusedConditional() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.index((i, v) -> Tuples.of("#" + (i + 1), v))
.filter(it -> true)
)
.expectFusion()
.expectNext(Tuples.of("#1", 0))
.expectNextMatches(t -> t.getT1().equals("#" + (t.getT2() + 1)))
.thenConsumeWhile(t -> t.getT1().equals("#" + (t.getT2() + 1)),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:19,代码来源:FluxIndexedFuseableTest.java
示例12: defaultNormal
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void defaultNormal() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.hide()
.index()
)
.expectNoFusionSupport()
.expectNext(Tuples.of(0L, 0))
.expectNextMatches(t -> t.getT1() == t.getT2().longValue())
.thenConsumeWhile(t -> t.getT1() == t.getT2().longValue(),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:19,代码来源:FluxIndexTest.java
示例13: defaultBackpressured
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void defaultBackpressured() {
AtomicLong counter = new AtomicLong(4);
StepVerifier.create(
Flux.range(0, 1000)
.hide()
.index()
, 0)
.expectNoFusionSupport()
.thenRequest(1)
.expectNext(Tuples.of(0L, 0))
.expectNoEvent(Duration.ofMillis(100))
.thenRequest(3)
.expectNext(Tuples.of(1L, 1))
.expectNext(Tuples.of(2L, 2))
.expectNext(Tuples.of(3L, 3))
.thenRequest(Long.MAX_VALUE)
.thenConsumeWhile(t -> t.getT1() == t.getT2().longValue(),
it -> counter.incrementAndGet())
.verifyComplete();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:25,代码来源:FluxIndexTest.java
示例14: defaultConditional
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void defaultConditional() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.hide()
.index()
.filter(it -> true)
)
.expectNoFusionSupport()
.expectNext(Tuples.of(0L, 0))
.expectNextMatches(t -> t.getT1() == t.getT2().longValue())
.thenConsumeWhile(t -> t.getT1() == t.getT2().longValue(),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:20,代码来源:FluxIndexTest.java
示例15: customNormal
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void customNormal() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.hide()
.index((i, v) -> Tuples.of("#" + (i + 1), v))
)
.expectNoFusionSupport()
.expectNext(Tuples.of("#1", 0))
.expectNextMatches(t -> t.getT1().equals("#" + (t.getT2() + 1)))
.thenConsumeWhile(t -> t.getT1().equals("#" + (t.getT2() + 1)),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:19,代码来源:FluxIndexTest.java
示例16: customBackpressured
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void customBackpressured() {
AtomicLong counter = new AtomicLong(4);
StepVerifier.create(
Flux.range(0, 1000)
.hide()
.index((i, v) -> Tuples.of("#" + (i + 1), v))
, 0)
.expectNoFusionSupport()
.thenRequest(1)
.expectNext(Tuples.of("#1", 0))
.expectNoEvent(Duration.ofMillis(100))
.thenRequest(3)
.expectNext(Tuples.of("#2", 1))
.expectNext(Tuples.of("#3", 2))
.expectNext(Tuples.of("#4", 3))
.thenRequest(Long.MAX_VALUE)
.thenConsumeWhile(t -> t.getT1().equals("#" + (t.getT2() + 1)),
it -> counter.incrementAndGet())
.verifyComplete();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:25,代码来源:FluxIndexTest.java
示例17: customConditional
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void customConditional() {
AtomicLong counter = new AtomicLong(2);
StepVerifier.create(
Flux.range(0, 1000)
.hide()
.index((i, v) -> Tuples.of("#" + (i + 1), v))
.filter(it -> true)
)
.expectNoFusionSupport()
.expectNext(Tuples.of("#1", 0))
.expectNextMatches(t -> t.getT1().equals("#" + (t.getT2() + 1)))
.thenConsumeWhile(t -> t.getT1().equals("#" + (t.getT2() + 1)),
it -> counter.incrementAndGet())
.expectComplete()
.verify();
assertThat(counter.get()).isEqualTo(1000);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:20,代码来源:FluxIndexTest.java
示例18: scanOperator
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void scanOperator() throws Exception {
Tuple2<String, String> tag1 = Tuples.of("foo", "oof");
Tuple2<String, String> tag2 = Tuples.of("bar", "rab");
Set<Tuple2<String, String>> tags = new HashSet<>();
tags.add(tag1);
tags.add(tag2);
Mono<Integer> source = Mono.just(1).map(i -> i);
MonoName<Integer> test = new MonoName<>(source, "foo", tags);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");
//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:20,代码来源:MonoNameTest.java
示例19: nextComplete
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void nextComplete() {
List<Tuple2<Signal, Context>> signalsAndContext = new ArrayList<>();
Mono.just(1)
.doOnEach(s -> signalsAndContext.add(Tuples.of(s, s.getContext())))
.subscriberContext(Context.of("foo", "bar"))
.subscribe();
assertThat(signalsAndContext)
.hasSize(2)
.allSatisfy(t2 -> {
assertThat(t2.getT1())
.isNotNull();
assertThat(t2.getT2().getOrDefault("foo", "baz"))
.isEqualTo("bar");
});
assertThat(signalsAndContext.stream().map(t2 -> t2.getT1().getType()))
.containsExactly(SignalType.ON_NEXT, SignalType.ON_COMPLETE);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:21,代码来源:MonoDoOnEachTest.java
示例20: nextError
import reactor.util.function.Tuples; //导入依赖的package包/类
@Test
public void nextError() {
List<Tuple2<Signal, Context>> signalsAndContext = new ArrayList<>();
Mono.just(0)
.map(i -> 10 / i)
.doOnEach(s -> signalsAndContext.add(Tuples.of(s,s.getContext())))
.subscriberContext(Context.of("foo", "bar"))
.subscribe();
assertThat(signalsAndContext)
.hasSize(1)
.allSatisfy(t2 -> {
assertThat(t2.getT1())
.isNotNull();
assertThat(t2.getT2().getOrDefault("foo", "baz"))
.isEqualTo("bar");
});
assertThat(signalsAndContext.stream().map(t2 -> t2.getT1().getType()))
.containsExactly(SignalType.ON_ERROR);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:22,代码来源:MonoDoOnEachTest.java
注:本文中的reactor.util.function.Tuples类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论