List of usage examples for org.apache.commons.lang3.tuple Pair getRight
public abstract R getRight();
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
From source file:com.streamsets.pipeline.lib.salesforce.PlatformEventRecordCreator.java
@Override @SuppressWarnings("unchecked") public Record createRecord(String sourceId, Object source) throws StageException { Pair<PartnerConnection, Map<String, Object>> pair = (Pair<PartnerConnection, Map<String, Object>>) source; PartnerConnection partnerConnection = pair.getLeft(); Map<String, Object> data = pair.getRight(); // Get new schema if necessary String schemaId = (String) data.get("schema"); if (schema == null || !schemaId.equals(schema.getProp("uuid"))) { schema = getSchemaMetadata(partnerConnection, schemaId); }// w ww. j a v a2 s .co m Record record = context.createRecord(sourceId); LinkedHashMap<String, Field> map = new LinkedHashMap<>(); Map<String, Object> payload = (Map<String, Object>) data.get("payload"); for (Map.Entry<String, Object> entry : payload.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); String type = schema.getField(key).schema().getType().getName(); if ("union".equals(type)) { for (Schema s : schema.getField(key).schema().getTypes()) { String t = s.getType().getName(); if (!("null".equals(t))) { type = t; break; } } } map.put(key, createField(val, type)); } record.getHeader().setAttribute(SOBJECT_TYPE_ATTRIBUTE, platformEventName); record.set(Field.createListMap(map)); return record; }
From source file:com.yahoo.elide.Elide.java
protected ElideResponse buildResponse(Pair<Integer, JsonNode> response) { try {/* w w w . j av a 2s .c o m*/ JsonNode responseNode = response.getRight(); Integer responseCode = response.getLeft(); String body = mapper.writeJsonApiDocument(responseNode); return new ElideResponse(responseCode, body); } catch (JsonProcessingException e) { return new ElideResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.toString()); } }
From source file:com.minlia.cloud.framework.test.common.web.AbstractDiscoverabilityLiveTest.java
@Test public void whenConsumingSimillarResourceName_thenRedirectedToCorrectResourceName() { final String simillarUriOfResource = getUri().substring(0, getUri().length() - 1); final Pair<String, String> readCredentials = getApi().getReadCredentials(); final RequestSpecification givenAuthenticated = auth.givenBasicAuthenticated(readCredentials.getLeft(), readCredentials.getRight()); final RequestSpecification readReq = givenAuthenticated.header(HttpHeaders.ACCEPT, marshaller.getMime()); final RequestSpecification customRequest = readReq .config(new RestAssuredConfig().redirect(new RedirectConfig().followRedirects(false))); final Response responseOfSimillarUri = getApi().findOneByUriAsResponse(simillarUriOfResource, customRequest);// ww w. java2s . c o m assertThat(responseOfSimillarUri.getStatusCode(), is(301)); }
From source file:com.yahoo.pulsar.common.naming.NamespaceBundlesTest.java
private void assertBundles(NamespaceBundleFactory utilityFactory, NamespaceName nsname, NamespaceBundle bundle, Pair<NamespaceBundles, List<NamespaceBundle>> splitBundles, int numBundles) throws Exception { NamespaceBundle bundle1 = splitBundles.getRight().get(0); NamespaceBundle bundle2 = splitBundles.getRight().get(1); NamespaceBundles nspaceBundles = splitBundles.getLeft(); Pair<NamespaceBundles, List<NamespaceBundle>> bundle1Split = splitBundlesUtilFactory(utilityFactory, nsname, nspaceBundles, bundle1, numBundles); assertBundleDivideInTwo(bundle1, bundle1Split.getRight(), numBundles); Pair<NamespaceBundles, List<NamespaceBundle>> bundle2Split = splitBundlesUtilFactory(utilityFactory, nsname, nspaceBundles, bundle2, numBundles); assertBundleDivideInTwo(bundle2, bundle2Split.getRight(), numBundles); }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.view.provider.KubernetesV2InstanceProvider.java
@Override public KubernetesV2Instance getInstance(String account, String location, String fullName) { Pair<KubernetesKind, String> parsedName; try {/* ww w. jav a2s .c om*/ parsedName = KubernetesManifest.fromFullResourceName(fullName); } catch (Exception e) { return null; } KubernetesKind kind = parsedName.getLeft(); String name = parsedName.getRight(); String key = Keys.infrastructure(kind, account, location, name); Optional<CacheData> optionalInstanceData = cacheUtils.getSingleEntry(kind.toString(), key); if (!optionalInstanceData.isPresent()) { return null; } CacheData instanceData = optionalInstanceData.get(); return KubernetesV2Instance.fromCacheData(instanceData); }
From source file:com.netflix.genie.agent.execution.statemachine.StateMachineAutoConfiguration.java
private void configureStates(final StateMachineBuilder.Builder<States, Events> builder, final Collection<Pair<States, StateAction>> statesWithActions) throws Exception { // Set up initial and terminal states (action-free) final StateConfigurer<States, Events> stateConfigurer = builder.configureStates().withStates() .initial(States.READY).end(States.END); // Set up the rest of the states with their corresponding action for (Pair<States, StateAction> stateWithAction : statesWithActions) { final States state = stateWithAction.getLeft(); final StateAction action = stateWithAction.getRight(); stateConfigurer// w ww .ja va2 s.com // Use entryAction because it is not interruptible. // StateAction is susceptible to cancellation in case of event-triggered transition out of the state. .state(state, action, null); log.info("Configured state {} with action {}", state, action.getClass().getSimpleName()); } }
From source file:com.shieldsbetter.sbomg.ModelClass.java
public void addOverriddenRootMethod(String methodName, TypeName returnType, Iterable<Pair<String, TypeName>> parameters, CodeBlock code) { MethodSpec.Builder b = MethodSpec.methodBuilder(methodName).addAnnotation(java.lang.Override.class) .returns(returnType).addCode(code).addModifiers(Modifier.PUBLIC); for (Pair<String, TypeName> param : parameters) { b.addParameter(param.getRight(), param.getLeft(), Modifier.FINAL); }//from w w w. j a va 2s . co m myRootMethods.add(b.build()); }
From source file:com.shieldsbetter.sbomg.ModelClass.java
public void addRootMethod(String methodName, TypeName returnType, Iterable<? extends Pair<String, TypeName>> parameters, CodeBlock code) { MethodSpec.Builder b = MethodSpec.methodBuilder(methodName).returns(returnType).addCode(code) .addModifiers(Modifier.PUBLIC); for (Pair<String, TypeName> param : parameters) { b.addParameter(param.getRight(), param.getLeft(), Modifier.FINAL); }/*from ww w .j ava2 s . c om*/ myRootMethods.add(b.build()); }
From source file:com.snaplogic.snaps.lunex.RequestBuilder.java
private String resolveUrl(final Document document) { try {//from ww w .jav a2s.c om String resourceSpecificUri = null; switch (snapType) { case Create: resourceSpecificUri = ServiceURIInfo.CR_URI_LIST.get(resource); break; case Read: resourceSpecificUri = ServiceURIInfo.RR_URI_LIST.get(resource); break; case Delete: resourceSpecificUri = ServiceURIInfo.DR_URI_LIST.get(resource); break; case Update: resourceSpecificUri = ServiceURIInfo.UR_URI_LIST.get(resource); break; } if (queryParams != null) { CharSequence source, target; for (Pair<String, ExpressionProperty> paramPair : queryParams) { source = new StringBuilder().append(OPENTAG).append(paramPair.getLeft()).append(CLOSETAG) .toString(); target = paramPair.getRight().eval(document).toString(); if (target == null) { target = StringUtils.EMPTY; } resourceSpecificUri = resourceSpecificUri.replace(source, target); } } return new StringBuilder().append(HTTP).append(COLON).append(DOUBLE_SLASH).append(IPAddress) .append(resourceSpecificUri).toString(); } catch (Exception e) { String msg = String.format(INVALID_URI, new StringBuilder().append(HTTP).append(COLON) .append(DOUBLE_SLASH).append(IPAddress).toString()); throw new ExecutionException(e, msg).withReason(msg).withResolution(INVALID_URI_RESOLUTION); } }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.view.provider.KubernetesV2LoadBalancerProvider.java
@Override public List<LoadBalancerProvider.Details> byAccountAndRegionAndName(String account, String namespace, String fullName) {/*from w w w .j a va 2 s . com*/ Pair<KubernetesKind, String> parsedName; try { parsedName = KubernetesManifest.fromFullResourceName(fullName); } catch (Exception e) { return null; } KubernetesKind kind = parsedName.getLeft(); String name = parsedName.getRight(); String key = Keys.infrastructure(kind, account, name, name); Optional<CacheData> optionalLoadBalancerData = cacheUtils.getSingleEntry(kind.toString(), key); if (!optionalLoadBalancerData.isPresent()) { return null; } CacheData loadBalancerData = optionalLoadBalancerData.get(); return new ArrayList<>(fromLoadBalancerCacheData(Collections.singletonList(loadBalancerData))); }