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:com.boozallen.cognition.ingest.storm.bolt.starter.LineRegexReplaceInRegionBoltTest.java
@Test public void testConfigureRegexRegions() throws Exception { XMLConfiguration conf = new XMLConfiguration(getResource(this.getClass(), "regexRegions.xml")); bolt.configureRegexRegions(conf);//ww w .j av a 2 s. c o m assertThat(bolt.groupSearchReplaceList.size(), is(2)); Triple<Pattern, String, String> entry0 = bolt.groupSearchReplaceList.get(0); Triple<Pattern, String, String> entry1 = bolt.groupSearchReplaceList.get(1); assertNotNull(entry0.getLeft()); assertThat(entry0.getMiddle(), is("regex0")); assertThat(entry0.getRight(), is("replacement0")); assertNotNull(entry1.getLeft()); assertThat(entry1.getMiddle(), is("regex1")); assertThat(entry1.getRight(), is("replacement1")); }
From source file:com.quancheng.saluki.gateway.zuul.filter.LimitAccessFilter.java
@Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); String auth = request.getHeader("Authorization"); String accessToken = auth.split(" ")[1]; ctx.set("LimitAccess", Boolean.TRUE); try {// ww w. ja va2 s .c om Triple<Long, String, Long> clientTriple = databaseUserDetailService.loadClientByToken(accessToken); String user = clientTriple.getMiddle(); Long intervalInMills = clientTriple.getLeft(); Long limits = clientTriple.getRight(); if (intervalInMills != null && intervalInMills != 0l && limits != null && limits != 0l) { if (!access(user, intervalInMills, limits)) { ctx.set("LimitAccess", Boolean.FALSE); ctx.setSendZuulResponse(false); ctx.setResponseStatusCode(HttpServletResponse.SC_BAD_REQUEST); ctx.setResponseBody("The times of usage is limited"); } } } catch (Throwable e) { } return null; }
From source file:blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.java
private static void handleMapForDamage(Set<Triple<Connection, Vec3d, Vec3d>> in, EntityLivingBase e, BlockPos here) {/* w w w.j ava2s . co m*/ final double KNOCKBACK_PER_DAMAGE = 10; if (!in.isEmpty()) { AxisAlignedBB eAabb = e.getEntityBoundingBox(); for (Triple<Connection, Vec3d, Vec3d> conn : in) if (conn.getLeft().cableType.canCauseDamage()) { double extra = conn.getLeft().cableType.getDamageRadius(); AxisAlignedBB includingExtra = eAabb.grow(extra).offset(-here.getX(), -here.getY(), -here.getZ()); boolean endpointsInEntity = includingExtra.contains(conn.getMiddle()) || includingExtra.contains(conn.getRight()); RayTraceResult rayRes = endpointsInEntity ? null : includingExtra.calculateIntercept(conn.getMiddle(), conn.getRight()); if (endpointsInEntity || (rayRes != null && rayRes.typeOfHit == RayTraceResult.Type.BLOCK)) { IImmersiveConnectable iic = toIIC(conn.getLeft().start, e.world); float damage = 0; if (iic != null) damage = iic.getDamageAmount(e, conn.getLeft()); if (damage == 0) { iic = toIIC(conn.getLeft().end, e.world); if (iic != null) damage = iic.getDamageAmount(e, conn.getLeft()); } if (damage != 0) { IEDamageSources.ElectricDamageSource dmg = IEDamageSources.causeWireDamage(damage, conn.getLeft().cableType.getElectricSource()); if (dmg.apply(e)) { damage = dmg.dmg; Vec3d v = e.getLookVec(); knockbackNoSource(e, damage / KNOCKBACK_PER_DAMAGE, v.x, v.z); iic.processDamage(e, damage, conn.getLeft()); } } } } } }
From source file:gobblin.ingestion.google.webmaster.UrlTriePrefixGrouperTest.java
@Test public void testWhenTrieSizeLessThanGroupSize1() { List<String> pages = Arrays.asList(_property + "13"); UrlTrie trie1 = new UrlTrie(_property, pages); UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie1, 1); Triple<String, FilterOperator, UrlTrieNode> next = grouper.next(); Assert.assertEquals(next.getLeft(), _property); Assert.assertEquals(next.getMiddle(), FilterOperator.CONTAINS); Assert.assertEquals(next.getRight().getValue(), Character.valueOf('/')); Assert.assertFalse(next.getRight().isExist()); Assert.assertFalse(grouper.hasNext()); }
From source file:gobblin.ingestion.google.webmaster.UrlTriePrefixGrouperTest.java
@Test public void testWhenTrieSizeLessThanGroupSize2() { List<String> pages = Arrays.asList(_property + "13"); UrlTrie trie1 = new UrlTrie(_property, pages); UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie1, 2); Triple<String, FilterOperator, UrlTrieNode> next = grouper.next(); Assert.assertEquals(next.getLeft(), _property); Assert.assertEquals(next.getMiddle(), FilterOperator.CONTAINS); Assert.assertEquals(next.getRight().getValue(), Character.valueOf('/')); Assert.assertFalse(next.getRight().isExist()); Assert.assertFalse(grouper.hasNext()); }
From source file:com.uber.hoodie.common.util.collection.converter.HoodieRecordConverter.java
@Override public HoodieRecord getData(byte[] bytes) { try {//from ww w . java 2 s.c om Triple<Pair<String, String>, Pair<byte[], byte[]>, byte[]> data = SerializationUtils.deserialize(bytes); Optional<GenericRecord> payload = Optional.empty(); HoodieRecordLocation currentLocation = null; HoodieRecordLocation newLocation = null; if (data.getRight().length > 0) { // This can happen if the record is deleted, the payload is optional with 0 bytes payload = Optional.of(HoodieAvroUtils.bytesToAvro(data.getRight(), schema)); } // Get the currentLocation for the HoodieRecord if (data.getMiddle().getLeft().length > 0) { currentLocation = SerializationUtils.deserialize(data.getMiddle().getLeft()); } // Get the newLocation for the HoodieRecord if (data.getMiddle().getRight().length > 0) { newLocation = SerializationUtils.deserialize(data.getMiddle().getRight()); } HoodieRecord<? extends HoodieRecordPayload> hoodieRecord = new HoodieRecord<>( new HoodieKey(data.getLeft().getKey(), data.getLeft().getValue()), ReflectionUtils.loadPayload(payloadClazz, new Object[] { payload }, Optional.class)); hoodieRecord.setCurrentLocation(currentLocation); hoodieRecord.setNewLocation(newLocation); return hoodieRecord; } catch (IOException io) { throw new HoodieNotSerializableException("Cannot de-serialize value from bytes", io); } }
From source file:com.netflix.genie.agent.execution.statemachine.StateMachineAutoConfiguration.java
private void configureTransitions(final StateMachineBuilder.Builder<States, Events> builder, final Collection<Triple<States, Events, States>> eventDrivenTransitions, final Collection<States> statesWithErrorTransition) throws Exception { final StateMachineTransitionConfigurer<States, Events> transitionConfigurer = builder .configureTransitions();//from w w w . ja v a 2s. co m // Set up event-driven transitions for (Triple<States, Events, States> transition : eventDrivenTransitions) { final States sourceState = transition.getLeft(); final States targetState = transition.getRight(); final Events event = transition.getMiddle(); transitionConfigurer.withExternal().source(sourceState).target(targetState).event(event).and(); log.info("Configured event-driven transition: ({}) -> [{}] -> ({})", sourceState, event, targetState); } // Set up transitions to HANDLE_ERROR state. for (States state : statesWithErrorTransition) { transitionConfigurer.withExternal().source(state).target(States.HANDLE_ERROR).event(Events.ERROR).and(); log.info("Configured error transition: ({}) -> ({})", state, States.HANDLE_ERROR); } // Add transition from HANDLE_ERROR to END transitionConfigurer.withExternal().source(States.HANDLE_ERROR).target(States.END) .event(Events.HANDLE_ERROR_COMPLETE); }
From source file:alfio.controller.TicketController.java
@RequestMapping(value = "/event/{eventName}/ticket/{ticketIdentifier}/code.png", method = RequestMethod.GET) public void generateTicketCode(@PathVariable("eventName") String eventName, @PathVariable("ticketIdentifier") String ticketIdentifier, 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 w ww. j av a2s .co m } Triple<Event, TicketReservation, Ticket> data = oData.get(); Event event = data.getLeft(); Ticket ticket = data.getRight(); String qrCodeText = ticket.ticketCode(event.getPrivateKey()); response.setContentType("image/png"); response.getOutputStream().write(ImageUtil.createQRCode(qrCodeText)); }
From source file:de.ellpeck.actuallyadditions.mod.blocks.BlockGreenhouseGlass.java
@Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { if (world.isRemote) return;/*from w w w. j a v a 2 s .c om*/ if (world.canBlockSeeSky(pos) && world.isDaytime()) { Triple<BlockPos, IBlockState, IGrowable> trip = firstBlock(world, pos); boolean once = false; if (trip != null) for (int i = 0; i < 3; i++) { IBlockState growState = i == 0 ? trip.getMiddle() : world.getBlockState(trip.getLeft()); if (growState.getBlock() == trip.getRight() && trip.getRight().canGrow(world, trip.getLeft(), growState, false)) { trip.getRight().grow(world, rand, trip.getLeft(), growState); once = true; } } if (once) world.playEvent(2005, trip.getMiddle().isOpaqueCube() ? trip.getLeft().up() : trip.getLeft(), 0); } }
From source file:alfio.controller.TicketController.java
private String internalShowTicket(String eventName, String ticketIdentifier, boolean ticketEmailSent, Model model, String backSuffix, Locale locale) { Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager .fetchCompleteAndAssigned(eventName, ticketIdentifier); if (!oData.isPresent()) { return "redirect:/event/" + eventName; }// ww w .j a v a 2 s .c o m Triple<Event, TicketReservation, Ticket> data = oData.get(); TicketCategory ticketCategory = ticketCategoryRepository.getByIdAndActive(data.getRight().getCategoryId(), data.getLeft().getId()); Organization organization = organizationRepository.getById(data.getLeft().getOrganizationId()); Event event = data.getLeft(); TicketReservation reservation = data.getMiddle(); model.addAttribute("ticket", data.getRight())// .addAttribute("reservation", reservation)// .addAttribute("event", event)// .addAttribute("ticketCategory", ticketCategory)// .addAttribute("organization", organization)// .addAttribute("ticketEmailSent", ticketEmailSent) .addAttribute("reservationId", ticketReservationManager.getShortReservationID(event, reservation.getId())) .addAttribute("deskPaymentRequired", Optional.ofNullable(reservation.getPaymentMethod()).orElse(PaymentProxy.STRIPE) .isDeskPaymentRequired()) .addAttribute("backSuffix", backSuffix).addAttribute("userLanguage", locale.getLanguage()) .addAttribute("pageTitle", "show-ticket.header.title") .addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName()) .addAttribute("validityStart", Optional.ofNullable(ticketCategory.getTicketValidityStart(event.getZoneId())) .orElse(event.getBegin())) .addAttribute("validityEnd", Optional.ofNullable(ticketCategory.getTicketValidityEnd(event.getZoneId())) .orElse(event.getEnd())) .addAttribute("ticketIdParam", "ticketId=" + ticketIdentifier); return "/event/show-ticket"; }