Example usage for org.springframework.data.util Pair getSecond

List of usage examples for org.springframework.data.util Pair getSecond

Introduction

In this page you can find the example usage for org.springframework.data.util Pair getSecond.

Prototype

public T getSecond() 

Source Link

Document

Returns the second element of the Pair .

Usage

From source file:com.ethercamp.harmony.service.BlockchainInfoService.java

@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof EmbeddedServletContainerInitializedEvent) {
        serverPort = ((EmbeddedServletContainerInitializedEvent) event).getEmbeddedServletContainer().getPort();

        final boolean isPrivateNetwork = env.getProperty("networkProfile", "").equalsIgnoreCase("private");
        final boolean isClassicNetwork = env.getProperty("networkProfile", "").equalsIgnoreCase("classic");

        // find out network name
        final Optional<String> blockHash = Optional.ofNullable(blockchain.getBlockByNumber(0l))
                .map(block -> Hex.toHexString(block.getHash()));
        final Pair<String, Optional<String>> networkInfo;
        if (isPrivateNetwork) {
            networkInfo = Pair.of("Private Miner Network", Optional.empty());
        } else if (isClassicNetwork) {
            networkInfo = Pair.of("Classic ETC", Optional.empty());
        } else {//from   w  w  w . ja v a 2  s  . com
            networkInfo = blockHash
                    .flatMap(hash -> Optional.ofNullable(BlockchainConsts.getNetworkInfo(env, hash)))
                    .orElse(Pair.of("Unknown network", Optional.empty()));
        }

        final boolean isContractsFeatureEnabled = env.getProperty("feature.contract.enabled", "false")
                .equalsIgnoreCase("true");
        if (!isContractsFeatureEnabled) {
            VM.setVmHook(null);
            log.info("Disabled VM hook due to contracts feature disabled");
        }

        initialInfo.set(new InitialInfoDTO(config.projectVersion() + "-" + config.projectVersionModifier(),
                "Hash: " + BuildInfo.buildHash + ",   Created: " + BuildInfo.buildTime,
                env.getProperty("app.version"), networkInfo.getFirst(), networkInfo.getSecond().orElse(null),
                blockHash.orElse(null), System.currentTimeMillis(), Hex.toHexString(config.nodeId()),
                serverPort, isPrivateNetwork, env.getProperty("portCheckerUrl"), config.bindIp(),
                isContractsFeatureEnabled));

        final String ANSI_RESET = "\u001B[0m";
        final String ANSI_BLUE = "\u001B[34m";
        System.out.println("EthereumJ database dir location: " + systemProperties.databaseDir());
        System.out.println("EthereumJ keystore dir location: " + keystore.getKeyStoreLocation());
        System.out.println(ANSI_BLUE + "Server started at http://localhost:" + serverPort + "" + ANSI_RESET);

        if (!config.getConfig().hasPath("logs.keepStdOut")
                || !config.getConfig().getBoolean("logs.keepStdOut")) {
            createLogAppenderForMessaging();
        }
    }
}

From source file:org.springframework.cloud.sleuth.annotation.SleuthSpanCreatorAspectMonoTests.java

@Test
public void shouldReturnNewSpanFromTraceContextOuter() {
    Mono<Pair<Pair<Long, Long>, Long>> mono = this.testBeanOuter.outerNewSpanInTraceContext();

    then(this.reporter.getSpans()).isEmpty();

    Pair<Pair<Long, Long>, Long> pair = mono.block();
    Long outerSpanIdBefore = pair.getFirst().getFirst();
    Long outerSpanIdAfter = pair.getFirst().getSecond();
    Long innerSpanId = pair.getSecond();

    then(outerSpanIdBefore).isEqualTo(outerSpanIdAfter).isNotEqualTo(innerSpanId);

    List<zipkin2.Span> spans = this.reporter.getSpans();
    then(spans).hasSize(2);/*from   w  w  w.  j  av a  2s .c  om*/
    then(spans.get(0).name()).isEqualTo("outer-span-in-trace-context");
    then(spans.get(0).id()).isEqualTo(toHexString(outerSpanIdBefore));
    then(spans.get(1).name()).isEqualTo("span-in-trace-context");
    then(spans.get(1).id()).isEqualTo(toHexString(innerSpanId));
    then(this.tracer.currentSpan()).isNull();
}

From source file:org.springframework.cloud.sleuth.annotation.SleuthSpanCreatorAspectMonoTests.java

@Test
public void shouldReturnNewSpanFromSubscriberContextOuter() {
    Mono<Pair<Pair<Long, Long>, Long>> mono = this.testBeanOuter.outerNewSpanInSubscriberContext();

    then(this.reporter.getSpans()).isEmpty();

    Pair<Pair<Long, Long>, Long> pair = mono.block();
    Long outerSpanIdBefore = pair.getFirst().getFirst();
    Long outerSpanIdAfter = pair.getFirst().getSecond();
    Long innerSpanId = pair.getSecond();

    then(outerSpanIdBefore).isEqualTo(outerSpanIdAfter).isNotEqualTo(innerSpanId);

    List<zipkin2.Span> spans = this.reporter.getSpans();
    then(spans).hasSize(2);//from w  w w .  j  a va2  s .  c om
    then(spans.get(0).name()).isEqualTo("outer-span-in-subscriber-context");
    then(spans.get(0).id()).isEqualTo(toHexString(outerSpanIdBefore));
    then(spans.get(1).name()).isEqualTo("span-in-subscriber-context");
    then(spans.get(1).id()).isEqualTo(toHexString(innerSpanId));
    then(this.tracer.currentSpan()).isNull();
}