本文整理汇总了Java中reactor.util.function.Tuples类的典型用法代码示例。如果您正苦于以下问题:Java Tuples类的具体用法?Java Tuples怎么用?Java Tuples使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tuples类属于reactor.util.function包,在下文中一共展示了Tuples类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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()));
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}