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

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

Introduction

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

Prototype

public abstract L getLeft();

Source Link

Document

Gets the left element from this pair.

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

Usage

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 {//from www  .  ja v a  2  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:net.lldp.checksims.algorithm.AlgorithmResults.java

public AlgorithmResults(Pair<Submission, Submission> ab, Percentable a, Percentable b) {
    this(ab.getLeft(), ab.getRight(), a, b);
}

From source file:com.github.rvesse.airline.restrictions.options.RequiredOnlyIfRestriction.java

@Override
public <T> void finalValidate(ParseState<T> state, OptionMetadata option) {
    if (this.names.isEmpty())
        return;/*from   ww w.  j av  a 2 s .  com*/

    Collection<Pair<OptionMetadata, Object>> parsedOptions = CollectionUtils.select(state.getParsedOptions(),
            new ParsedOptionFinder(option));

    // If this option was seen then the required criteria has been fulfilled
    // regardless of whether any of the triggering options was actually
    // present
    if (parsedOptions.size() > 0)
        return;

    // Were any of the options that would trigger the required restriction
    // present?
    for (Pair<OptionMetadata, Object> otherOption : state.getParsedOptions()) {
        if (otherOption.getLeft().equals(option))
            continue;

        for (String name : this.names) {
            if (otherOption.getLeft().getOptions().contains(name))
                throw new ParseOptionMissingException(option.getTitle());
        }
    }
}

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: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.minlia.cloud.framework.client.template.AbstractBaseClientRestTemplate.java

protected HttpHeaders readHeadersWithAuth() {
    final Pair<String, String> defaultCredentials = getReadCredentials();
    return readHeadersWithAuth(defaultCredentials.getLeft(), defaultCredentials.getRight());
}

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.streamsets.datacollector.event.handler.remote.TestRemoteStateEventListener.java

@Test
public void testRemoteStateEventListener() throws Exception {
    RemoteStateEventListener remoteStateEventListener = new RemoteStateEventListener(new Configuration());
    remoteStateEventListener.init();/*from w  w w .j  a  va 2 s .  c  o m*/
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(RemoteDataCollector.IS_REMOTE_PIPELINE, true);
    PipelineState pipelineState = new PipelineStateImpl("user", "name", "0", PipelineStatus.RUNNING, "msg", -1,
            attributes, ExecutionMode.STANDALONE, "", 1, -1);
    remoteStateEventListener.onStateChange(null, pipelineState, null, null,
            Collections.singletonMap(Source.POLL_SOURCE_OFFSET_KEY, "offset:1000"));
    Collection<Pair<PipelineState, Map<String, String>>> pipelineStateAndOffset = remoteStateEventListener
            .getPipelineStateEvents();
    Assert.assertEquals(1, pipelineStateAndOffset.size());
    Assert.assertEquals(PipelineStatus.RUNNING, pipelineStateAndOffset.iterator().next().getLeft().getStatus());
    Assert.assertEquals("offset:1000",
            pipelineStateAndOffset.iterator().next().getRight().get(Source.POLL_SOURCE_OFFSET_KEY));
    Assert.assertEquals(0, remoteStateEventListener.getPipelineStateEvents().size());

    PipelineState pipelineStateDeleted = new PipelineStateImpl("user", "name", "0", PipelineStatus.DELETED,
            "msg", -1, attributes, ExecutionMode.STANDALONE, "", 1, -1);
    remoteStateEventListener.onStateChange(null, pipelineState, null, null,
            Collections.singletonMap(Source.POLL_SOURCE_OFFSET_KEY, "offset:old"));
    remoteStateEventListener.onStateChange(null, pipelineStateDeleted, null, null,
            Collections.singletonMap(Source.POLL_SOURCE_OFFSET_KEY, "offset:new"));
    pipelineStateAndOffset = remoteStateEventListener.getPipelineStateEvents();
    Assert.assertEquals(2, pipelineStateAndOffset.size());
    Iterator<Pair<PipelineState, Map<String, String>>> iterator = pipelineStateAndOffset.iterator();
    iterator.next();
    Pair<PipelineState, Map<String, String>> pair = iterator.next();
    Assert.assertEquals(PipelineStatus.DELETED, pair.getLeft().getStatus());
    Assert.assertEquals("offset:new", pair.getRight().get(Source.POLL_SOURCE_OFFSET_KEY));
    Assert.assertEquals(0, remoteStateEventListener.getPipelineStateEvents().size());
}

From source file:alfio.controller.support.TemplateProcessorTest.java

private void assertDimensionsUnder300x150(Pair<String, String> p) {
    Map<String, String> parameters = new HashMap<>();
    parameters.put(FileBlobMetadata.ATTR_IMG_WIDTH, p.getLeft());
    parameters.put(FileBlobMetadata.ATTR_IMG_HEIGHT, p.getRight());
    FileBlobMetadata metadata = mock(FileBlobMetadata.class);
    when(metadata.getAttributes()).thenReturn(parameters);
    Event e = mock(Event.class);
    when(e.getFileBlobIdIsPresent()).thenReturn(true);
    FileUploadManager fileUploadManager = mock(FileUploadManager.class);
    when(fileUploadManager.findMetadata(e.getFileBlobId())).thenReturn(Optional.of(metadata));
    TemplateProcessor.extractImageModel(e, fileUploadManager).ifPresent(imageData -> {
        assertTrue(imageData.getImageWidth() <= 300);
        assertTrue(imageData.getImageHeight() <= 150);
    });//from  w ww .ja  v  a2  s  .c o m
}

From source file:com.minlia.cloud.framework.client.template.AbstractBaseClientRestTemplate.java

protected HttpHeaders writeHeadersWithAuth() {
    final Pair<String, String> defaultCredentials = getWriteCredentials();
    return writeHeadersWithAuth(defaultCredentials.getLeft(), defaultCredentials.getRight());
}