Example usage for org.apache.commons.lang3.tuple Pair getRight

List of usage examples for org.apache.commons.lang3.tuple Pair getRight

Introduction

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

Prototype

public abstract R getRight();

Source Link

Document

Gets the right element from this pair.

When treated as a key-value pair, this is the value.

Usage

From source file:io.knotx.mocks.adapter.MockActionAdapterHandler.java

private AdapterResponse replyTransition(ClientRequest request, JsonObject transitions) {
    final Pair<Optional<String>, JsonObject> result = getTransitionResult(request, transitions);

    final JsonObject resultBody = result.getRight().put("form", toJsonObject(request.getFormAttributes()));

    final String data = resultBody.toString();
    final ClientResponse clientResponse = new ClientResponse().setHeaders(headers(request, data))
            .setStatusCode(HttpResponseStatus.OK.code()).setBody(Buffer.buffer(data));

    final AdapterResponse response = new AdapterResponse().setResponse(clientResponse);

    final Optional<String> transition = result.getLeft();
    if (transition.isPresent()) {
        response.setSignal(transition.get());
    }//from   w ww .  ja  v  a 2  s.c  o m
    return response;
}

From source file:it.polimi.diceH2020.SPACE4CloudWS.fileManagement.FileUtility.java

public boolean delete(@NotNull Pair<File, File> pFiles) {
    boolean deletedLeft = delete(pFiles.getLeft());
    return delete(pFiles.getRight()) && deletedLeft;
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesManifestOperationDescription.java

@JsonIgnore
public KubernetesCoordinates getPointCoordinates() {
    Pair<KubernetesKind, String> parsedName = KubernetesManifest.fromFullResourceName(manifestName);

    return KubernetesCoordinates.builder().namespace(location).kind(parsedName.getLeft())
            .name(parsedName.getRight()).build();
}

From source file:de.tntinteractive.portalsammler.engine.MapReaderTest.java

@Test
public void testMultipleMaps() throws Exception {
    final String input = "test123\n" + " \n" + " \n" + ".\n" + "test456\n" + " \n" + " \n" + ".";
    final MapReader r = createReader(input);
    final Pair<String, Map<String, String>> p1 = r.readNext();
    assertEquals("test123", p1.getLeft());
    assertEquals(Collections.singletonMap("", ""), p1.getRight());
    final Pair<String, Map<String, String>> p2 = r.readNext();
    assertEquals("test456", p2.getLeft());
    assertEquals(Collections.singletonMap("", ""), p2.getRight());
    assertNull(r.readNext());/*  w ww.j a  v  a2s . com*/
}

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

public Order[] getOrderArray(Root<T> root, CriteriaBuilder criteriaBuilder) {
    List<Order> orderList = new ArrayList<Order>();

    for (Pair<SingularAttribute<T, ?>, Direction> directionedColumn : directionedColumnList) {
        Direction direction = directionedColumn.getRight();
        SingularAttribute<T, ?> column = directionedColumn.getLeft();
        Path<?> path = root.get(column);
        Order order = null;/*from ww w  . j av  a 2 s.  c o  m*/
        switch (direction) {
        case ASC:
            order = criteriaBuilder.asc(path);
            break;
        case DES:
            order = criteriaBuilder.desc(path);
            break;
        }
        orderList.add(order);
    }
    return orderList.toArray(new Order[orderList.size()]);
}

From source file:edu.uci.ics.asterix.metadata.feeds.FeedUtil.java

public static JobSpecification alterJobSpecificationForFeed(JobSpecification spec,
        FeedConnectionId feedConnectionId, Map<String, String> feedPolicyProperties) {

    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Original Job Spec:" + spec);
    }//ww  w . j a  va2 s . com

    JobSpecification altered = new JobSpecification(spec.getFrameSize());
    Map<OperatorDescriptorId, IOperatorDescriptor> operatorMap = spec.getOperatorMap();
    boolean preProcessingRequired = preProcessingRequired(feedConnectionId);
    // copy operators
    String operandId = null;
    Map<OperatorDescriptorId, OperatorDescriptorId> oldNewOID = new HashMap<OperatorDescriptorId, OperatorDescriptorId>();
    FeedMetaOperatorDescriptor metaOp = null;
    for (Entry<OperatorDescriptorId, IOperatorDescriptor> entry : operatorMap.entrySet()) {
        operandId = FeedRuntimeId.DEFAULT_OPERAND_ID;
        IOperatorDescriptor opDesc = entry.getValue();
        if (opDesc instanceof FeedCollectOperatorDescriptor) {
            FeedCollectOperatorDescriptor orig = (FeedCollectOperatorDescriptor) opDesc;
            FeedCollectOperatorDescriptor fiop = new FeedCollectOperatorDescriptor(altered,
                    orig.getFeedConnectionId(), orig.getSourceFeedId(), (ARecordType) orig.getOutputType(),
                    orig.getRecordDescriptor(), orig.getFeedPolicyProperties(), orig.getSubscriptionLocation());
            oldNewOID.put(opDesc.getOperatorId(), fiop.getOperatorId());
        } else if (opDesc instanceof AsterixLSMTreeInsertDeleteOperatorDescriptor) {
            operandId = ((AsterixLSMTreeInsertDeleteOperatorDescriptor) opDesc).getIndexName();
            metaOp = new FeedMetaOperatorDescriptor(altered, feedConnectionId, opDesc, feedPolicyProperties,
                    FeedRuntimeType.STORE, false, operandId);
            oldNewOID.put(opDesc.getOperatorId(), metaOp.getOperatorId());
        } else if (opDesc instanceof AsterixLSMInvertedIndexInsertDeleteOperatorDescriptor) {
            operandId = ((AsterixLSMInvertedIndexInsertDeleteOperatorDescriptor) opDesc).getIndexName();
            metaOp = new FeedMetaOperatorDescriptor(altered, feedConnectionId, opDesc, feedPolicyProperties,
                    FeedRuntimeType.STORE, false, operandId);
            oldNewOID.put(opDesc.getOperatorId(), metaOp.getOperatorId());

        } else {
            FeedRuntimeType runtimeType = null;
            boolean enableSubscriptionMode = false;
            boolean createMetaOp = true;
            OperatorDescriptorId opId = null;
            if (opDesc instanceof AlgebricksMetaOperatorDescriptor) {
                IPushRuntimeFactory runtimeFactory = ((AlgebricksMetaOperatorDescriptor) opDesc).getPipeline()
                        .getRuntimeFactories()[0];
                if (runtimeFactory instanceof AssignRuntimeFactory) {
                    IConnectorDescriptor connectorDesc = spec.getOperatorInputMap().get(opDesc.getOperatorId())
                            .get(0);
                    IOperatorDescriptor sourceOp = spec.getProducer(connectorDesc);
                    if (sourceOp instanceof FeedCollectOperatorDescriptor) {
                        runtimeType = preProcessingRequired ? FeedRuntimeType.COMPUTE : FeedRuntimeType.OTHER;
                        enableSubscriptionMode = preProcessingRequired;
                    } else {
                        runtimeType = FeedRuntimeType.OTHER;
                    }
                } else if (runtimeFactory instanceof EmptyTupleSourceRuntimeFactory) {
                    runtimeType = FeedRuntimeType.ETS;
                } else {
                    runtimeType = FeedRuntimeType.OTHER;
                }
            } else {
                if (opDesc instanceof AbstractSingleActivityOperatorDescriptor) {
                    runtimeType = FeedRuntimeType.OTHER;
                } else {
                    opId = altered.createOperatorDescriptorId(opDesc);
                    createMetaOp = false;
                }
            }
            if (createMetaOp) {
                metaOp = new FeedMetaOperatorDescriptor(altered, feedConnectionId, opDesc, feedPolicyProperties,
                        runtimeType, enableSubscriptionMode, operandId);
                opId = metaOp.getOperatorId();
            }
            oldNewOID.put(opDesc.getOperatorId(), opId);
        }
    }

    // copy connectors
    Map<ConnectorDescriptorId, ConnectorDescriptorId> connectorMapping = new HashMap<ConnectorDescriptorId, ConnectorDescriptorId>();
    for (Entry<ConnectorDescriptorId, IConnectorDescriptor> entry : spec.getConnectorMap().entrySet()) {
        IConnectorDescriptor connDesc = entry.getValue();
        ConnectorDescriptorId newConnId = altered.createConnectorDescriptor(connDesc);
        connectorMapping.put(entry.getKey(), newConnId);
    }

    // make connections between operators
    for (Entry<ConnectorDescriptorId, Pair<Pair<IOperatorDescriptor, Integer>, Pair<IOperatorDescriptor, Integer>>> entry : spec
            .getConnectorOperatorMap().entrySet()) {
        IConnectorDescriptor connDesc = altered.getConnectorMap().get(connectorMapping.get(entry.getKey()));
        Pair<IOperatorDescriptor, Integer> leftOp = entry.getValue().getLeft();
        Pair<IOperatorDescriptor, Integer> rightOp = entry.getValue().getRight();

        IOperatorDescriptor leftOpDesc = altered.getOperatorMap()
                .get(oldNewOID.get(leftOp.getLeft().getOperatorId()));
        IOperatorDescriptor rightOpDesc = altered.getOperatorMap()
                .get(oldNewOID.get(rightOp.getLeft().getOperatorId()));

        altered.connect(connDesc, leftOpDesc, leftOp.getRight(), rightOpDesc, rightOp.getRight());
    }

    // prepare for setting partition constraints
    Map<OperatorDescriptorId, List<LocationConstraint>> operatorLocations = new HashMap<OperatorDescriptorId, List<LocationConstraint>>();
    Map<OperatorDescriptorId, Integer> operatorCounts = new HashMap<OperatorDescriptorId, Integer>();

    for (Constraint constraint : spec.getUserConstraints()) {
        LValueConstraintExpression lexpr = constraint.getLValue();
        ConstraintExpression cexpr = constraint.getRValue();
        OperatorDescriptorId opId;
        switch (lexpr.getTag()) {
        case PARTITION_COUNT:
            opId = ((PartitionCountExpression) lexpr).getOperatorDescriptorId();
            operatorCounts.put(opId, (int) ((ConstantExpression) cexpr).getValue());
            break;
        case PARTITION_LOCATION:
            opId = ((PartitionLocationExpression) lexpr).getOperatorDescriptorId();

            IOperatorDescriptor opDesc = altered.getOperatorMap().get(oldNewOID.get(opId));
            List<LocationConstraint> locations = operatorLocations.get(opDesc.getOperatorId());
            if (locations == null) {
                locations = new ArrayList<>();
                operatorLocations.put(opDesc.getOperatorId(), locations);
            }
            String location = (String) ((ConstantExpression) cexpr).getValue();
            LocationConstraint lc = new LocationConstraint();
            lc.location = location;
            lc.partition = ((PartitionLocationExpression) lexpr).getPartition();
            locations.add(lc);
            break;
        }
    }

    // set absolute location constraints
    for (Entry<OperatorDescriptorId, List<LocationConstraint>> entry : operatorLocations.entrySet()) {
        IOperatorDescriptor opDesc = altered.getOperatorMap().get(oldNewOID.get(entry.getKey()));
        Collections.sort(entry.getValue(), new Comparator<LocationConstraint>() {

            @Override
            public int compare(LocationConstraint o1, LocationConstraint o2) {
                return o1.partition - o2.partition;
            }
        });
        String[] locations = new String[entry.getValue().size()];
        for (int i = 0; i < locations.length; ++i) {
            locations[i] = entry.getValue().get(i).location;
        }
        PartitionConstraintHelper.addAbsoluteLocationConstraint(altered, opDesc, locations);
    }

    // set count constraints
    for (Entry<OperatorDescriptorId, Integer> entry : operatorCounts.entrySet()) {
        IOperatorDescriptor opDesc = altered.getOperatorMap().get(oldNewOID.get(entry.getKey()));
        if (!operatorLocations.keySet().contains(entry.getKey())) {
            PartitionConstraintHelper.addPartitionCountConstraint(altered, opDesc, entry.getValue());
        }
    }

    // useConnectorSchedulingPolicy
    altered.setUseConnectorPolicyForScheduling(spec.isUseConnectorPolicyForScheduling());

    // connectorAssignmentPolicy
    altered.setConnectorPolicyAssignmentPolicy(spec.getConnectorPolicyAssignmentPolicy());

    // roots
    for (OperatorDescriptorId root : spec.getRoots()) {
        altered.addRoot(altered.getOperatorMap().get(oldNewOID.get(root)));
    }

    // jobEventListenerFactory
    altered.setJobletEventListenerFactory(spec.getJobletEventListenerFactory());

    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("New Job Spec:" + altered);
    }

    return altered;

}

From source file:com.mirth.connect.client.ui.codetemplate.ContextTreeTableCellEditor.java

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
        int column) {
    Pair<Integer, ?> pair = (Pair<Integer, ?>) value;
    if (pair != null) {
        checkBox.setState(pair.getLeft());
        if (pair.getRight() instanceof String) {
            contextType = null;/* w ww.j  ava 2  s.  com*/
            checkBox.setText((String) pair.getRight());
        } else {
            contextType = (ContextType) pair.getRight();
            checkBox.setText(contextType.getDisplayName());
        }
    }

    MirthTreeTable treeTable = (MirthTreeTable) table;
    JTree tree = (JTree) treeTable.getCellRenderer(0, treeTable.getHierarchicalColumn());
    panel.setOffset(tree.getRowBounds(row).x);
    panel.setBackground(row % 2 == 0 ? UIConstants.HIGHLIGHTER_COLOR : UIConstants.BACKGROUND_COLOR);
    checkBox.setBackground(panel.getBackground());
    return panel;
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.description.servergroup.KubernetesServerGroupOperationDescription.java

@JsonIgnore
public KubernetesCoordinates getCoordinates() {
    Pair<KubernetesKind, String> parsedName = KubernetesManifest.fromFullResourceName(serverGroupName);

    return KubernetesCoordinates.builder().namespace(region).kind(parsedName.getLeft())
            .name(parsedName.getRight()).build();
}

From source file:com.github.tddts.jet.config.spring.postprocessor.LoadContentAnnotationBeanPostProcessor.java

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    Pair<Class<?>, Object> typeObjectPair = SpringUtil.checkForDinamicProxy(bean);
    Class<?> type = typeObjectPair.getLeft();
    Object target = typeObjectPair.getRight();

    try {// w  ww.  j  ava2 s  .co  m

        for (Field field : type.getDeclaredFields()) {
            if (field.isAnnotationPresent(LoadContent.class) && String.class.equals(field.getType())) {

                field.setAccessible(true);
                String fileName = getFileName(target, field);

                if (!StringUtils.isEmpty(fileName)) {
                    field.set(target, Util.loadContent(fileName));
                }
            }
        }
    } catch (Exception e) {
        throw new BeanInitializationException(e.getMessage(), e);
    }

    return bean;
}

From source file:io.codis.nedis.util.AbstractNedisBuilder.java

public final void validateGroupConfig() {
    if (group == null && channelClass != null) {
        throw new IllegalArgumentException("group is null but channel is not");
    }//w ww  .j  a v a 2 s.c o  m
    if (channelClass == null && group != null) {
        throw new IllegalArgumentException("channel is null but group is not");
    }
    if (group == null) {
        Pair<EventLoopGroup, Class<? extends Channel>> defaultEventLoopConfig = defaultEventLoopConfig();
        group = defaultEventLoopConfig.getLeft();
        channelClass = defaultEventLoopConfig.getRight();
    }
}