Example usage for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair

List of usage examples for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair.

Prototype

public ImmutablePair(final L left, final R right) 

Source Link

Document

Create a new pair instance.

Usage

From source file:com.pinterest.terrapin.server.OnlineOfflineStateModelFactory.java

static Pair<String, String> getHdfsPathAndPartitionNum(Message message) {
    // Since the partition names in helix are of the form resource$120 etc., we need to
    // strip out the resource from partition name.
    String partitionNum = message.getPartitionName().substring(message.getResourceName().length() + 1);
    String partitionName = TerrapinUtil.formatPartitionName(Integer.parseInt(partitionNum));
    String hdfsPath = TerrapinUtil.helixResourceToHdfsDir(message.getResourceName()) + "/" + partitionName;

    return new ImmutablePair(hdfsPath, partitionNum);
}

From source file:net.mintern.primitive.pair.ImmutableObjDoublePair.java

@Override
public ImmutablePair<L, Double> boxed() {
    return new ImmutablePair<>(left, right);
}

From source file:net.mintern.primitive.pair.ImmutableObjBooleanPair.java

@Override
public ImmutablePair<L, Boolean> boxed() {
    return new ImmutablePair<>(left, right);
}

From source file:eu.bittrade.libs.steemj.BaseIT.java

/**
 * Call this method in case the tests should be fired against the TestNet
 * endpoint using the WebSocket protocol..
 * /* ww  w . j a v  a 2 s .c  o m*/
 * @throws URISyntaxException
 *             If the URL is wrong.
 */
public static void configureTestNetWebsocketEndpoint() throws URISyntaxException {
    ArrayList<Pair<URI, Boolean>> endpoints = new ArrayList<>();

    ImmutablePair<URI, Boolean> webSocketEndpoint;
    webSocketEndpoint = new ImmutablePair<>(new URI("wss://testnet.steem.vc"), true);

    endpoints.add(webSocketEndpoint);
    config.setEndpointURIs(endpoints);
}

From source file:com.ex.data.PlintDirection.java

/**
 * Create one of Plint Direction. Left and right pairs will be connected.
 * @param connL Left Connector /*from  w  w  w  . j a  v  a  2 s.  c  om*/
 * @param plintNumberL Plint Number in the left Connector
 * @param connR Right Connector 
 * @param plintNumberR Plint Number in the right Connector
 */
public PlintDirection(Connector connL, int plintNumberL, Connector connR, int plintNumberR) {
    super(new ImmutablePair<Long, Integer>(connL.getId(), plintNumberL),
            new ImmutablePair<Long, Integer>(connR.getId(), plintNumberR));
    if (plintNumberL > connL.getNumberOfPlints().intValue()) {
        throw new IllegalArgumentException();
    }
    if (plintNumberR > connR.getNumberOfPlints().intValue()) {
        throw new IllegalArgumentException();
    }
}

From source file:com.nextdoor.bender.operation.conditional.ConditionalOperationFactory.java

@Override
public void setConf(AbstractConfig config) {
    this.config = (ConditionalOperationConfig) config;

    List<Pair<FilterOperation, List<OperationProcessor>>> cases = new ArrayList<Pair<FilterOperation, List<OperationProcessor>>>();
    OperationFactoryFactory off = new OperationFactoryFactory();

    for (Condition caze : this.config.getConditions()) {
        List<OperationProcessor> processorsInCase = new ArrayList<OperationProcessor>();

        /*/*ww  w.j  a va2s  .c  o m*/
         * Create {@OperationProcessor}s from configs
         */
        for (OperationConfig opConfig : caze.getOperations()) {
            try {
                processorsInCase.add(new OperationProcessor(off.getFactory(opConfig)));
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        FilterOperation filter;
        try {
            filter = (FilterOperation) off.getFactory(caze.getCondition()).newInstance();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }

        cases.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(filter, processorsInCase));
    }

    this.cases = cases;
}

From source file:com.artistech.tuio.dispatch.TuioSink.java

private void broadcast(Object obj) {
    String type = obj.getClass().getSimpleName();
    switch (serialization) {
    case PROTOBUF: {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
            boolean success = false;
            for (ProtoConverter service : services) {
                if (service.supportsConversion(obj)) {
                    service.convertToProtobuf(obj).build().writeTo(baos);
                    baos.flush();/*from w  w w  .  ja v a  2 s  . co  m*/
                    success = true;
                    break;
                }
            }
            if (success) {
                mailbox.addMessage(new ImmutablePair<>(type, baos.toByteArray()));
            }
        } catch (IOException ex) {
            Logger.getLogger(TuioSink.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
        break;
    case JSON:
        try {
            mailbox.addMessage(new ImmutablePair<>(type, mapper.writeValueAsString(obj).getBytes()));
        } catch (JsonProcessingException ex) {
            Logger.getLogger(TuioSink.class.getName()).log(Level.SEVERE, null, ex);
        }
        break;
    case OBJECT:
        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
                ObjectOutput out = new ObjectOutputStream(bos)) {
            out.writeObject(obj);
            mailbox.addMessage(new ImmutablePair<>(type, bos.toByteArray()));
        } catch (java.io.IOException ex) {
            logger.error(null, ex);
        }
        break;
    }
}

From source file:be.ordina.msdashboard.aggregators.health.HealthIndicatorsAggregator.java

@Override
public Observable<Node> aggregateNodes() {
    Observable<Observable<Node>> observableObservable = getServiceIdsFromDiscoveryClient()
            .map(id -> new ImmutablePair<String, String>(id,
                    uriResolver.resolveHealthCheckUrl(discoveryClient.getInstances(id).get(0))))
            .doOnNext(pair -> logger.info("Creating health observable: " + pair))
            .map(pair -> getHealthNodesFromService(pair.getLeft(), pair.getRight()))
            .doOnNext(el -> logger.debug("Unmerged health observable: " + el))
            .doOnCompleted(() -> logger.info("Completed getting all health observables"));
    return Observable.merge(observableObservable)
            .doOnNext(el -> logger.debug("Merged health node: " + el.getId()))
            .doOnCompleted(() -> logger.info("Completed merging all health observables"));
}

From source file:com.pinterest.terrapin.server.ResourcePartitionMap.java

public void addReader(String resource, String partition, Reader r) throws UnsupportedOperationException {
    Pair<String, String> readerMapKey = new ImmutablePair(resource, partition);
    synchronized (this) {
        if (readerMap.containsKey(readerMapKey)) {
            // If we already have a reader available, log as an error and return.
            LOG.warn("Resource : " + resource + " Partition : " + partition + " already exists.");
            return;
        }/*from   ww w.  j a  v  a2 s .  c om*/
        readerMap.put(readerMapKey, r);
        incrementPartitionCount(resource);
    }
}

From source file:cl.troncador.delfin.query.constraint.PrepareOrderAdapter.java

/**
 * Adds the./*from   www  .  j ava2  s.  c  o  m*/
 *
 * @param column the column
 */
public void add(SingularAttribute<T, ?> column) {
    Pair<SingularAttribute<T, ?>, Direction> pair = new ImmutablePair<SingularAttribute<T, ?>, Direction>(
            column, Direction.ASC);
    directionedColumnList.add(pair);
}