List of usage examples for org.apache.commons.lang3.tuple Triple getMiddle
public abstract M getMiddle();
Gets the middle element from this triple.
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToCharTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @throws X Any throwable from this functions action * @see org.apache.commons.lang3.tuple.Triple */// www . ja v a2s. co m default char applyAsCharThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyAsCharThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToLongTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @throws X Any throwable from this functions action * @see org.apache.commons.lang3.tuple.Triple *///www . j a v a 2 s . c o m default long applyAsLongThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyAsLongThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImpl.java
@Transactional @Override/*from ww w. j ava 2 s.com*/ public Pair<ModelAndView, WebFlow> startSigning(final HttpServletRequest request, final String document, final String stoken) throws IOException { Triple<DocSignQueueMessage, ArchiveDTO, QueueMessage> p = this.signingService.findAssets(document, stoken); DocSignQueueMessage msg = p.getLeft(); ArchiveDTO dto = p.getMiddle(); updateSignaturesToRequired(dto.getForms().values()); List<FlowState> states = new ArrayList<>(); states.add(new FlowState(START)); FlowState s1 = new FlowState(DEFAULT, null, "flow/summary"); s1.setParameter("geoLocation", Boolean.TRUE); states.add(s1); states.add(new FlowState(END, null, "flow/complete")); WebFlow flow = startFlow(request, msg.getFolderid(), null, dto, WorkflowEditorServiceImpl.class, states); flow.setParameter("docsignmsg", msg); return Pair.of(new ModelAndView("redirect:/flow/workflow?execution=" + flow.getSessionKey()), flow); }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToFloatTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @throws X Any throwable from this functions action * @see org.apache.commons.lang3.tuple.Triple *//*from ww w. j a va 2 s . co m*/ default float applyAsFloatThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyAsFloatThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToShortTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @throws X Any throwable from this functions action * @see org.apache.commons.lang3.tuple.Triple *///from ww w. j av a 2 s .com default short applyAsShortThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyAsShortThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToDoubleTriFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @throws X Any throwable from this functions action * @see org.apache.commons.lang3.tuple.Triple */// www. ja v a2 s . co m default double applyAsDoubleThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyAsDoubleThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:blusunrize.immersiveengineering.common.EventHandler.java
@SubscribeEvent public void onMinecartUpdate(MinecartUpdateEvent event) { if (event.getMinecart().ticksExisted % 3 == 0 && event.getMinecart().hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { ShaderWrapper wrapper = event.getMinecart().getCapability(CapabilityShader.SHADER_CAPABILITY, null); if (wrapper != null) { Vec3d prevPosVec = new Vec3d(event.getMinecart().prevPosX, event.getMinecart().prevPosY, event.getMinecart().prevPosZ); Vec3d movVec = prevPosVec.subtract(event.getMinecart().posX, event.getMinecart().posY, event.getMinecart().posZ); if (movVec.lengthSquared() > 0.0001) { movVec = movVec.normalize(); Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry .getStoredShaderAndCase(wrapper); if (shader != null) shader.getMiddle().getEffectFunction().execute(event.getMinecart().world, shader.getLeft(), null, shader.getRight().getShaderType(), prevPosVec.add(0, .25, 0).add(movVec), movVec.scale(1.5f), .25f); }//from w ww . j a v a 2 s . co m } } }
From source file:com.vmware.identity.openidconnect.server.AuthenticationRequestProcessor.java
public Pair<ModelAndView, HttpResponse> process() { // parse authn request (and if that fails, see if you can still construct an error response off of the partially parsed request) ClientID clientId;//from w w w . j a v a 2 s .co m URI redirectUri; AuthenticationErrorResponse parseErrorResponse; try { this.authnRequest = AuthenticationRequest.parse(this.httpRequest); clientId = this.authnRequest.getClientID(); redirectUri = this.authnRequest.getRedirectURI(); parseErrorResponse = null; } catch (AuthenticationRequest.ParseException e) { if (e.getClientID() != null && e.getRedirectURI() != null && e.createAuthenticationErrorResponse(this.isAjaxRequest) != null) { clientId = e.getClientID(); redirectUri = e.getRedirectURI(); parseErrorResponse = e.createAuthenticationErrorResponse(this.isAjaxRequest); } else { LoggerUtils.logFailedRequest(logger, e.getErrorObject(), e); return Pair.of((ModelAndView) null, HttpResponse.createErrorResponse(e.getErrorObject())); } } // check that tenant, client, and redirect_uri are registered (if not, return error to browser, not client) try { if (this.tenant == null) { this.tenant = this.tenantInfoRetriever.getDefaultTenantName(); } this.tenantInfo = this.tenantInfoRetriever.retrieveTenantInfo(this.tenant); this.clientInfo = this.clientInfoRetriever.retrieveClientInfo(this.tenant, clientId); if (!this.clientInfo.getRedirectURIs().contains(redirectUri)) { throw new ServerException(ErrorObject.invalidRequest("unregistered redirect_uri")); } } catch (ServerException e) { LoggerUtils.logFailedRequest(logger, e); return Pair.of((ModelAndView) null, HttpResponse.createErrorResponse(e.getErrorObject())); } // if tenant, client, and redirect_uri are registered, we can return authn error response to the client instead of browser if (parseErrorResponse != null) { LoggerUtils.logFailedRequest(logger, parseErrorResponse.getErrorObject()); return Pair.of((ModelAndView) null, parseErrorResponse.toHttpResponse()); } // authenticate client try { authenticateClient(); } catch (ServerException e) { LoggerUtils.logFailedRequest(logger, e); return Pair.of((ModelAndView) null, authnErrorResponse(e).toHttpResponse()); } // process login information (username/password or session), if failed, return error message to browser so javascript can consume it LoginProcessor p = new LoginProcessor(this.personUserAuthenticator, this.sessionManager, this.messageSource, this.locale, this.httpRequest, this.tenant); Triple<PersonUser, SessionID, LoginMethod> loginResult; try { loginResult = p.process(); } catch (LoginProcessor.LoginException e) { LoggerUtils.logFailedRequest(logger, e.getErrorObject(), e); return Pair.of((ModelAndView) null, e.toHttpResponse()); } PersonUser personUser = loginResult.getLeft(); SessionID sessionId = loginResult.getMiddle(); LoginMethod loginMethod = loginResult.getRight(); // if no person user, return login form if (personUser == null) { try { return Pair.of(generateLoginForm(), (HttpResponse) null); } catch (ServerException e) { LoggerUtils.logFailedRequest(logger, e); return Pair.of((ModelAndView) null, authnErrorResponse(e).toHttpResponse()); } } // we have a person user, process authn request for this person user try { AuthenticationSuccessResponse authnSuccessResponse = (this.authnRequest.getResponseType() .contains(ResponseTypeValue.AUTHORIZATION_CODE)) ? processAuthzCodeResponse(personUser, sessionId) : processIDTokenResponse(personUser, sessionId); if (loginMethod == null) { this.sessionManager.update(sessionId, this.clientInfo); } else { this.sessionManager.add(sessionId, personUser, loginMethod, this.clientInfo); } HttpResponse httpResponse = authnSuccessResponse.toHttpResponse(); httpResponse.addCookie(loggedInSessionCookie(sessionId)); return Pair.of((ModelAndView) null, httpResponse); } catch (ServerException e) { LoggerUtils.logFailedRequest(logger, e); return Pair.of((ModelAndView) null, authnErrorResponse(e).toHttpResponse()); } }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testConfirmReservation() throws Exception { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 1, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null)); Triple<Event, String, TicketReservation> testResult = performExistingCategoryTest(categories, true, Collections.singletonList(2), false, true, 0, AVAILABLE_SEATS); assertNotNull(testResult);/* w w w. j a v a 2 s . c om*/ Result<Triple<TicketReservation, List<Ticket>, Event>> result = adminReservationManager.confirmReservation( testResult.getLeft().getShortName(), testResult.getRight().getId(), testResult.getMiddle()); assertTrue(result.isSuccess()); Triple<TicketReservation, List<Ticket>, Event> triple = result.getData(); assertEquals(TicketReservation.TicketReservationStatus.COMPLETE, triple.getLeft().getStatus()); triple.getMiddle().forEach(t -> assertEquals(Ticket.TicketStatus.ACQUIRED, t.getStatus())); assertTrue(emailMessageRepository.findByEventId(triple.getRight().getId(), 0, 50, null).isEmpty()); ticketCategoryRepository.findByEventId(triple.getRight().getId()) .forEach(tc -> assertTrue(specialPriceRepository.findAllByCategoryId(tc.getId()).stream() .allMatch(sp -> sp.getStatus() == SpecialPrice.Status.TAKEN))); assertFalse(ticketRepository.findAllReservationsConfirmedButNotAssigned(triple.getRight().getId()) .contains(triple.getLeft().getId())); }
From source file:alfio.controller.api.support.TicketHelper.java
private Triple<ValidationResult, Event, Ticket> assignTicket(UpdateTicketOwnerForm updateTicketOwner, Optional<Errors> bindingResult, HttpServletRequest request, Optional<UserDetails> userDetails, Triple<Event, TicketReservation, Ticket> result) { Ticket t = result.getRight();/* ww w . j a v a 2 s .c o m*/ final Event event = result.getLeft(); if (t.getLockedAssignment()) { //in case of locked assignment, fullName and Email will be overwritten updateTicketOwner.setFirstName(t.getFirstName()); updateTicketOwner.setLastName(t.getLastName()); updateTicketOwner.setFullName(t.getFullName()); updateTicketOwner.setEmail(t.getEmail()); } final TicketReservation ticketReservation = result.getMiddle(); List<TicketFieldConfiguration> fieldConf = ticketFieldRepository .findAdditionalFieldsForEvent(event.getId()); ValidationResult validationResult = Validator .validateTicketAssignment(updateTicketOwner, fieldConf, bindingResult, event) .ifSuccess(() -> updateTicketOwner(updateTicketOwner, request, t, event, ticketReservation, userDetails)); return Triple.of(validationResult, event, ticketRepository.findByUUID(t.getUuid())); }