List of usage examples for org.apache.commons.lang3.tuple Triple getLeft
public abstract L getLeft();
Gets the left element from this triple.
From source file:at.gridtec.lambda4j.function.tri.to.ToLongTriFunction.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} * @see org.apache.commons.lang3.tuple.Triple *///ww w .j a v a2 s .c o m default long applyAsLong(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsLong(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToShortTriFunction.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} * @see org.apache.commons.lang3.tuple.Triple *//*from w w w.j a v a 2 s . c o m*/ default short applyAsShort(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsShort(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.tri.to.ToDoubleTriFunction.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} * @see org.apache.commons.lang3.tuple.Triple *//*from w ww . j av a 2 s.c o m*/ default double applyAsDouble(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return applyAsDouble(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:com.drisoftie.action.async.AsyncAction.java
@Override public void registerAction(List<ActionBinding<ViewT>> bindings) { ClassLoader cl = this.getClass().getClassLoader(); for (ActionBinding<ViewT> binding : bindings) { Class<?>[] actions = new Class<?>[binding.registrations.size()]; for (int i = 0; i < actions.length; i++) { actions[i] = binding.registrations.get(i).getLeft(); }/*from ww w . j av a 2 s .c om*/ binding.actionHandler = Proxy.newProxyInstance(cl, actions, this); } for (ActionBinding<ViewT> actionBinding : bindings) { if (actionBinding.view != null) { for (Triple<Class<?>, String, String[]> reg : actionBinding.registrations) { if (StringUtils.isNotEmpty(reg.getMiddle())) { try { Method regMethod = actionBinding.view.getClass().getMethod(reg.getMiddle(), reg.getLeft()); if (regMethod != null) { regMethod.invoke(actionBinding.view, actionBinding.actionHandler); } } catch (NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) { // do nothing if binding fails if (BuildConfig.DEBUG) { Log.v(getClass().getSimpleName(), e.getClass().getName() + " for callback" + reg.getLeft().getName()); } } } } } } this.bindings = bindings; }
From source file:at.gridtec.lambda4j.function.tri.ThrowableTriFunction.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 w w w .j av a2s . c om default R applyThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.predicate.tri.TriPredicate.java
/** * Applies this predicate to the given tuple. * * @param tuple The tuple to be applied to the predicate * @return The return value from the predicate, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Triple *//*from ww w .j a va 2s .c o m*/ default boolean test(@Nonnull Triple<T, U, V> tuple) { Objects.requireNonNull(tuple); return test(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testDistributeSeatsFirstCategoryIsBounded() throws Exception { List<TicketCategoryModification> categories = getPreSalesTicketCategoryModifications(true, 10, true, 10); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/*ww w. ja va 2s . c om*/ Event event = pair.getKey(); TicketCategory firstCategory = eventManager.loadTicketCategories(event).stream() .filter(t -> t.getName().equals("defaultFirst")).findFirst() .orElseThrow(IllegalStateException::new); configurationManager.saveCategoryConfiguration(firstCategory.getId(), event.getId(), Collections.singletonList(new ConfigurationModification(null, ConfigurationKeys.MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "1")), pair.getRight() + "_owner"); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_PRE_REGISTRATION, "true"); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); boolean result = waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH); assertTrue(result); List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(1, subscriptions.size()); Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions .get(0); assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress()); TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(firstCategory.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testDistributeSeatsFirstCategoryIsUnbounded() throws Exception { List<TicketCategoryModification> categories = getPreSalesTicketCategoryModifications(false, AVAILABLE_SEATS, true, 10);/*from ww w . ja v a2 s. c o m*/ Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository); Event event = pair.getKey(); TicketCategory firstCategory = eventManager.loadTicketCategories(event).stream() .filter(t -> t.getName().equals("defaultFirst")).findFirst() .orElseThrow(IllegalStateException::new); configurationManager.saveCategoryConfiguration(firstCategory.getId(), event.getId(), Collections.singletonList(new ConfigurationModification(null, ConfigurationKeys.MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "1")), pair.getRight() + "_owner"); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_PRE_REGISTRATION, "true"); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); boolean result = waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH); assertTrue(result); List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(1, subscriptions.size()); Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions .get(0); assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress()); TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(firstCategory.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }
From source file:alfio.controller.TicketController.java
@RequestMapping(value = "/event/{eventName}/ticket/{ticketIdentifier}/download-ticket", method = RequestMethod.GET) public void generateTicketPdf(@PathVariable("eventName") String eventName, @PathVariable("ticketIdentifier") String ticketIdentifier, HttpServletRequest request, HttpServletResponse response) throws IOException, WriterException { Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager .fetchCompleteAndAssigned(eventName, ticketIdentifier); if (!oData.isPresent()) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return;/*from ww w . j a v a2 s . c o m*/ } Triple<Event, TicketReservation, Ticket> data = oData.get(); Ticket ticket = data.getRight(); response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "attachment; filename=ticket-" + ticketIdentifier + ".pdf"); try (OutputStream os = response.getOutputStream()) { PdfBoxRenderer renderer = preparePdfTicket(request, data.getLeft(), data.getMiddle(), ticket) .generate(ticket); if (renderer != null) { renderer.createPDF(os); } } }
From source file:alfio.controller.api.admin.AdminReservationApiController.java
private TicketReservationDescriptor toReservationDescriptor(String reservationId, Triple<TicketReservation, List<Ticket>, Event> triple) { List<SerializablePair<TicketCategory, List<Ticket>>> tickets = triple.getMiddle().stream() .collect(Collectors.groupingBy(Ticket::getCategoryId)).entrySet().stream() .map(entry -> SerializablePair.of( eventManager.getTicketCategoryById(entry.getKey(), triple.getRight().getId()), entry.getValue()))/*w w w .j a va 2 s . co m*/ .collect(Collectors.toList()); TicketReservation reservation = triple.getLeft(); return new TicketReservationDescriptor(reservation, ticketReservationManager.orderSummaryForReservationId( reservationId, triple.getRight(), Locale.forLanguageTag(reservation.getUserLanguage())), tickets); }