List of usage examples for org.apache.commons.lang3.tuple Triple getRight
public abstract R getRight();
Gets the right element from this triple.
From source file:at.gridtec.lambda4j.predicate.tri.ThrowableTriPredicate.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} * @throws X Any throwable from this predicates action * @see org.apache.commons.lang3.tuple.Triple *///ww w . j a va 2s. c om default boolean testThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return testThrows(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 w w . j a va2 s.c o m } } }
From source file:blusunrize.immersiveengineering.common.items.ItemRailgun.java
@Override public void onUsingTick(ItemStack stack, EntityLivingBase user, int count) { int inUse = this.getMaxItemUseDuration(stack) - count; if (inUse > getChargeTime(stack) && inUse % 20 == user.getRNG().nextInt(20)) { user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.spark, SoundCategory.PLAYERS, .8f + (.2f * user.getRNG().nextFloat()), .5f + (.5f * user.getRNG().nextFloat())); Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry .getStoredShaderAndCase(stack); if (shader != null) { Vec3d pos = Utils.getLivingFrontPos(user, .4375, user.height * .75, user.getActiveHand() == EnumHand.MAIN_HAND ? user.getPrimaryHand() : user.getPrimaryHand().opposite(), false, 1);/*from w w w . j a v a2s . c o m*/ shader.getMiddle().getEffectFunction().execute(user.world, shader.getLeft(), stack, shader.getRight().getShaderType(), pos, null, .0625f); } } }
From source file:com.drisoftie.action.async.BaseAsyncAction.java
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object result = null;//from w w w. j a v a 2 s . com String methodName = method.getName(); for (ActionBinding<ViewT> binding : bindings) { if (proxy == binding.actionHandler) { if (binding.hasInvokeLimitations) { boolean found = false; for (Triple<Class<?>, String, String[]> reg : binding.registrations) { if (ArrayUtils.isNotEmpty(reg.getRight())) { for (String methodLimit : reg.getRight()) { if (StringUtils.equals(methodName, methodLimit)) { found = true; break; } } } } if (!found) { // if (BuildConfig.DEBUG) { // // Log.e("Proxy Action Library", "No method found: " + methodName); // } return null; } } result = onActionPrepare(methodName, args, tag1, tag2, tags); if (runWorkThread && !skipWorkThread) { IFinishedHandler<ResultT> handler = new IFinishedHandler<ResultT>() { private ViewT v; private String methodName; private Object[] methodArgs; /** * Initializer method to allow a custom constructor workaround. * * @param v the given view * @param methodName the invoked method name * @param methodArgs given method arguments * @return {@code this} */ private IFinishedHandler<ResultT> init(ViewT v, String methodName, Object[] methodArgs) { this.v = v; this.methodName = methodName; this.methodArgs = methodArgs; return this; } @Override public void onFinished(ResultT result) { Runnable runner = new Runnable() { private ResultT result; public Runnable init(ResultT result) { this.result = result; return this; } @Override public void run() { BaseAsyncAction.this.onActionAfterWork(methodName, methodArgs, result, tag1, tag2, tags); } }.init(result); if (v != null) { invokeRunnableOnViewImpl(v, runner); } else { invokeRunnableOnUiThread(runner); } } }.init(binding.view, methodName, args); ActionThread action = new ActionThread(handler, methodName, args); actionThreads.add(action); action.start(); break; } } } skipWorkThread = false; return result; }
From source file:blusunrize.immersiveengineering.common.items.ItemRailgun.java
@Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase user, int timeLeft) { if (user instanceof EntityPlayer) { int inUse = this.getMaxItemUseDuration(stack) - timeLeft; ItemNBTHelper.remove(stack, "inUse"); if (inUse < getChargeTime(stack)) return; int energy = IEConfig.Tools.railgun_consumption; float energyMod = 1 + this.getUpgrades(stack).getFloat("consumption"); energy = (int) (energy * energyMod); if (this.extractEnergy(stack, energy, true) == energy) { ItemStack ammo = findAmmo((EntityPlayer) user); if (!ammo.isEmpty()) { Vec3d vec = user.getLookVec(); float speed = 20; EntityRailgunShot shot = new EntityRailgunShot(user.world, user, vec.x * speed, vec.y * speed, vec.z * speed, Utils.copyStackWithAmount(ammo, 1)); ammo.shrink(1);// w w w.j a v a 2s . c o m if (ammo.getCount() <= 0) ((EntityPlayer) user).inventory.deleteStack(ammo); user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.railgunFire, SoundCategory.PLAYERS, 1, .5f + (.5f * user.getRNG().nextFloat())); this.extractEnergy(stack, energy, false); if (!world.isRemote) user.world.spawnEntity(shot); Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry .getStoredShaderAndCase(stack); if (shader != null) { Vec3d pos = Utils.getLivingFrontPos(user, .75, user.height * .75, user.getActiveHand() == EnumHand.MAIN_HAND ? user.getPrimaryHand() : user.getPrimaryHand().opposite(), false, 1); shader.getMiddle().getEffectFunction().execute(world, shader.getLeft(), stack, shader.getRight().getShaderType(), pos, user.getForward(), .125f); } } } } }
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);// w ww . j a va 2s .co m 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);//w ww. j ava 2 s .co 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.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testAssignTicketToWaitingQueueUnboundedCategorySelected() { LocalDateTime start = LocalDateTime.now().minusHours(1); LocalDateTime end = LocalDateTime.now().plusHours(1); List<TicketCategoryModification> categories = Arrays.asList( new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null), new TicketCategoryModification(null, "default2", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();//www. j a v a 2s . co m List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId()); TicketCategory first = ticketCategories.get(0); TicketCategory second = ticketCategories.get(1); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(second.getId()); TicketReservationModification tr3 = new TicketReservationModification(); tr3.setAmount(1); tr3.setTicketCategoryId(first.getId()); reserveTickets(event, first, AVAILABLE_SEATS - 2); String reservationIdSingleFirst = reserveTickets(event, second, 1); String reservationIdSingleSecond = reserveTickets(event, second, 1); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); assertTrue(waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", first.getId(), Locale.ENGLISH)); assertTrue(waitingQueueManager.subscribe(event, new CustomerName("John Doe 2", "John", "Doe 2", event), "john@doe2.com", second.getId(), Locale.ENGLISH)); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingleFirst, false); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingleSecond, false); List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(2, subscriptions.size()); Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions .get(0); assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress()); TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(first.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); subscriptionDetail = subscriptions.get(1); assertEquals("john@doe2.com", subscriptionDetail.getLeft().getEmailAddress()); reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(second.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 testAssignTicketToWaitingQueueBoundedCategory() { LocalDateTime start = LocalDateTime.now().minusMinutes(2); LocalDateTime end = LocalDateTime.now().plusMinutes(20); List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();//from ww w . j av a2s . co m TicketCategory bounded = ticketCategoryRepository.findByEventId(event.getId()).get(0); TicketReservationModification tr = new TicketReservationModification(); tr.setAmount(AVAILABLE_SEATS - 1); tr.setTicketCategoryId(bounded.getId()); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(bounded.getId()); TicketReservationWithOptionalCodeModification multi = new TicketReservationWithOptionalCodeModification(tr, Optional.empty()); TicketReservationWithOptionalCodeModification single = new TicketReservationWithOptionalCodeModification( tr2, Optional.empty()); String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(multi), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TotalPrice reservationCost = ticketReservationManager.totalReservationCostWithVAT(reservationId); PaymentResult result = ticketReservationManager.confirm("", null, event, reservationId, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCost, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(result.isSuccessful()); String reservationIdSingle = ticketReservationManager.createTicketReservation(event, Collections.singletonList(single), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TotalPrice reservationCostSingle = ticketReservationManager .totalReservationCostWithVAT(reservationIdSingle); PaymentResult resultSingle = ticketReservationManager.confirm("", null, event, reservationIdSingle, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCostSingle, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(resultSingle.isSuccessful()); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); assertTrue( waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH)); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingle, false); 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(bounded.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 testAssignTicketToWaitingQueueUnboundedCategory() { LocalDateTime start = LocalDateTime.now().minusMinutes(1); LocalDateTime end = LocalDateTime.now().plusMinutes(20); List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();// ww w. j a v a2 s. c om TicketCategory unbounded = ticketCategoryRepository.findByEventId(event.getId()).get(0); TicketReservationModification tr = new TicketReservationModification(); tr.setAmount(AVAILABLE_SEATS - 1); tr.setTicketCategoryId(unbounded.getId()); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(unbounded.getId()); TicketReservationWithOptionalCodeModification multi = new TicketReservationWithOptionalCodeModification(tr, Optional.empty()); TicketReservationWithOptionalCodeModification single = new TicketReservationWithOptionalCodeModification( tr2, Optional.empty()); String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(multi), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TotalPrice reservationCost = ticketReservationManager.totalReservationCostWithVAT(reservationId); PaymentResult result = ticketReservationManager.confirm("", null, event, reservationId, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCost, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(result.isSuccessful()); String reservationIdSingle = ticketReservationManager.createTicketReservation(event, Collections.singletonList(single), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TotalPrice reservationCostSingle = ticketReservationManager .totalReservationCostWithVAT(reservationIdSingle); PaymentResult resultSingle = ticketReservationManager.confirm("", null, event, reservationIdSingle, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCostSingle, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(resultSingle.isSuccessful()); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); assertTrue( waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH)); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingle, false); 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(unbounded.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }