org.apache.commons.lang3.tuple.Triple Java Examples
The following examples show how to use
org.apache.commons.lang3.tuple.Triple.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WaitingQueueManagerIntegrationTest.java From alf.io with GNU General Public License v3.0 | 6 votes |
@Test public void testDistributeSeatsFirstCategoryIsUnbounded() throws Exception { List<TicketCategoryModification> categories = getPreSalesTicketCategoryModifications(false, AVAILABLE_SEATS, true, 10); 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), "[email protected]", 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("[email protected]", 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())); }
Example #2
Source File: FSSorter.java From twister2 with Apache License 2.0 | 6 votes |
public Object next() { HeapNode min = heap.extractMin(); int list = min.listNo; FilePart p = openList.get(list); List<Tuple> keyValues = p.keyValues.getLeft(); if (keyValues.size() <= p.currentIndex) { String fileName = folder + "/part_" + list; // we need to load the next file, we don't need to do anything for in-memory // also if the file reached end, we don't need to do anything if (list < noOfFiles && p.keyValues.getMiddle() < p.keyValues.getRight()) { Triple<List<Tuple>, Long, Long> values = FileLoader.openFilePart(fileName, p.keyValues.getMiddle(), openBytes, keyType, dataType, deserializer); // set the new values to the list p.keyValues = values; } } return min.data; }
Example #3
Source File: GalleryInitResult.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
public GalleryInitResult(Parcel parcel) { initPosition = parcel.readInt(); shouldWaitForPageLoaded = parcel.readInt() == 1; int n = parcel.readInt(); attachments = new ArrayList<>(n); for (int i=0; i<n; ++i) { AttachmentModel attachment = new AttachmentModel(); attachment.type = parcel.readInt(); attachment.size = parcel.readInt(); attachment.thumbnail = parcel.readString(); attachment.path = parcel.readString(); attachment.width = parcel.readInt(); attachment.height = parcel.readInt(); attachment.originalName = parcel.readString(); attachment.isSpoiler = parcel.readInt() == 1; String hash = parcel.readString(); String post = parcel.readString(); attachments.add(Triple.of(attachment, hash, post)); } }
Example #4
Source File: LiveCode.java From doov with Apache License 2.0 | 6 votes |
private static void modelDiff() { FieldModel sample_1 = SampleModels.wrapper(); FieldModel sample_2 = SampleModels.wrapper(); sample_1.set(FAVORITE_SITE_NAME_3, null); sample_1.set(FAVORITE_SITE_URL_3, null); sample_2.set(FAVORITE_SITE_NAME_1, "LesFurets.com"); sample_2.set(FAVORITE_SITE_URL_1, "www.lesfurets.com"); sample_2.set(EMAILS_PREFERENCES, Collections.emptyList()); /* stream all key-values pair from both models */ Stream.concat(sample_1.stream().map(buildRight), sample_2.stream().map(buildLeft)) /* merging key-value pair in a map */ .collect(Collectors.toMap(Triple::getMiddle, Function.identity(), merge)) /* filter to keep only key with 2 differents values */ .values().stream().filter(isNotSame) /* print keys with differents values */ .forEach(System.out::println); }
Example #5
Source File: WaitingQueueSubscriptionProcessorTest.java From alf.io with GNU General Public License v3.0 | 6 votes |
@Test void processPendingTickets() { when(configurationManager.getFor(eq(Set.of(ENABLE_WAITING_QUEUE, ENABLE_PRE_REGISTRATION)), any())) .thenReturn(Map.of( ENABLE_WAITING_QUEUE, new ConfigurationManager.MaybeConfiguration(ENABLE_WAITING_QUEUE, new ConfigurationKeyValuePathLevel( "", "true", null)), ENABLE_PRE_REGISTRATION, new ConfigurationManager.MaybeConfiguration(ENABLE_PRE_REGISTRATION) )); when(messageSource.getMessage(anyString(), any(), eq(Locale.ENGLISH))).thenReturn("subject"); when(subscription.getLocale()).thenReturn(Locale.ENGLISH); when(subscription.getEmailAddress()).thenReturn("me"); ZonedDateTime expiration = ZonedDateTime.now().plusDays(1); when(waitingQueueManager.distributeSeats(eq(event))).thenReturn(Stream.of(Triple.of(subscription, reservation, expiration))); String reservationId = "reservation-id"; when(ticketReservationManager.createTicketReservation(eq(event), anyList(), anyList(), any(Date.class), eq(Optional.empty()), any(Locale.class), eq(true))).thenReturn(reservationId); processor.handleWaitingTickets(); verify(ticketReservationManager).createTicketReservation(eq(event), eq(Collections.singletonList(reservation)), anyList(), eq(Date.from(expiration.toInstant())), eq(Optional.empty()), eq(Locale.ENGLISH), eq(true)); verify(notificationManager).sendSimpleEmail(eq(event), eq(reservationId), eq("me"), eq("subject"), any(TemplateGenerator.class)); }
Example #6
Source File: LineRegexReplaceInRegionBoltTest.java From cognition with Apache License 2.0 | 6 votes |
@Test public void testConfigureRegexRegions() throws Exception { XMLConfiguration conf = new XMLConfiguration(getResource(this.getClass(), "regexRegions.xml")); bolt.configureRegexRegions(conf); 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")); }
Example #7
Source File: RunBenchmarks.java From yauaa with Apache License 2.0 | 6 votes |
@Test public void runBenchmarks() { uaa = UserAgentAnalyzer .newBuilder() .withoutCache() .preheat(10000) .build(); List<Triple<Counter, String, String>> testCases = createTestCasesList(); System.gc(); // Avoid gc during tests for (int run = 1; run < 10000; run++) { if (run % 100 == 0) { System.gc(); // Avoid gc during tests LOG.info("Did {} runs", run); } testCases.forEach(this::doTest); } testCases.forEach(this::printResults); }
Example #8
Source File: SonosLinkController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@PostMapping public ModelAndView doPost(HttpServletRequest request) { String linkCode = request.getParameter("linkCode"); String username = request.getParameter("j_username"); String password = request.getParameter("j_password"); Triple<String, String, Instant> data = sonosService.getInitiatedLinkCodeData(linkCode); if (data == null) { return new ModelAndView("sonosLinkFailure", "model", Map.of("linkCode", linkCode, "errorCode", "sonos.linkcode.notfound")); } try { Authentication authenticate = authManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); if (authenticate.isAuthenticated()) { if (sonosService.addSonosAuthorization(username, linkCode, data.getLeft(), data.getMiddle(), data.getRight())) { return new ModelAndView("sonosSuccess", "model", Collections.emptyMap()); } else { return new ModelAndView("sonosLinkFailure", "model", Map.of("linkCode", linkCode, "errorCode", "sonos.linkcode.alreadyused")); } } else { return loginFailed(linkCode); } } catch (BadCredentialsException e) { return loginFailed(linkCode); } }
Example #9
Source File: AdminReservationRequestManager.java From alf.io with GNU General Public License v3.0 | 6 votes |
private Result<Triple<TicketReservation, List<Ticket>, Event>> processReservation(AdminReservationRequest request, Event event, User user) { DefaultTransactionDefinition definition = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_NESTED); TransactionTemplate template = new TransactionTemplate(transactionManager, definition); return template.execute(status -> { var savepoint = status.createSavepoint(); try { String eventName = event.getShortName(); String username = user.getUsername(); Result<Triple<TicketReservation, List<Ticket>, Event>> result = adminReservationManager.createReservation(request.getBody(), eventName, username) .flatMap(r -> adminReservationManager.confirmReservation(eventName, r.getLeft().getId(), username, orEmpty(request.getBody().getNotification()))); if(!result.isSuccess()) { status.rollbackToSavepoint(savepoint); } return result; } catch(Exception ex) { status.rollbackToSavepoint(savepoint); return Result.error(singletonList(ErrorCode.custom("", ex.getMessage()))); } }); }
Example #10
Source File: WaitingQueueManagerTest.java From alf.io with GNU General Public License v3.0 | 6 votes |
@Test void processPreReservations() { Ticket ticket = mock(Ticket.class); WaitingQueueSubscription subscription = mock(WaitingQueueSubscription.class); when(subscription.isPreSales()).thenReturn(true); when(eventRepository.countExistingTickets(eq(eventId))).thenReturn(10); when(event.getZoneId()).thenReturn(ZoneId.systemDefault()); when(waitingQueueRepository.countWaitingPeople(eq(eventId))).thenReturn(1); when(ticketRepository.countWaiting(eq(eventId))).thenReturn(0); when(configurationManager.getFor(eq(ENABLE_PRE_REGISTRATION), any())).thenReturn(new ConfigurationManager.MaybeConfiguration(ENABLE_PRE_REGISTRATION, new ConfigurationKeyValuePathLevel(null, "true", null))); when(configurationManager.getFor(eq(WAITING_QUEUE_RESERVATION_TIMEOUT), any())).thenReturn(new ConfigurationManager.MaybeConfiguration(WAITING_QUEUE_RESERVATION_TIMEOUT)); when(ticketRepository.selectWaitingTicketsForUpdate(eventId, Ticket.TicketStatus.PRE_RESERVED.name(), 1)).thenReturn(Collections.singletonList(ticket)); when(waitingQueueRepository.loadAllWaitingForUpdate(eventId)).thenReturn(Collections.singletonList(subscription)); when(waitingQueueRepository.loadWaiting(eventId, 1)).thenReturn(Collections.singletonList(subscription)); Stream<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> stream = manager.distributeSeats(event); assertEquals(1L, stream.count()); verify(waitingQueueRepository).loadAllWaitingForUpdate(eq(eventId)); verify(waitingQueueRepository).loadWaiting(eq(eventId), eq(1)); verify(ticketRepository).countWaiting(eq(eventId)); verify(ticketRepository, never()).revertToFree(eq(eventId)); verify(ticketRepository).countPreReservedTickets(eq(eventId)); verify(ticketRepository).preReserveTicket(anyList()); verify(ticketRepository).selectWaitingTicketsForUpdate(eq(eventId), anyString(), anyInt()); }
Example #11
Source File: UrlTriePrefixGrouperTest.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * The trie is: * / * 0 * 1* 2* */ @Test public void testGrouping1() { UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "01", _property + "02")); UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, 1); ArrayList<String> chars = new ArrayList<>(); ArrayList<FilterOperator> operators = new ArrayList<>(); while (grouper.hasNext()) { Triple<String, FilterOperator, UrlTrieNode> group = grouper.next(); chars.add(group.getLeft()); operators.add(group.getMiddle()); } Assert.assertEquals(new String[]{_property + "01", _property + "02"}, chars.toArray()); Assert.assertEquals(new FilterOperator[]{FilterOperator.CONTAINS, FilterOperator.CONTAINS}, operators.toArray()); }
Example #12
Source File: RsaKeyTest.java From azure-keyvault-java with MIT License | 6 votes |
@Test public void testRsa15() throws Exception { RsaKey key = getTestRsaKey(); // Wrap and Unwrap Pair<byte[], String> wrapped = key.wrapKeyAsync(CEK, Rsa15.ALGORITHM_NAME).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert assertEquals(Rsa15.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt Triple<byte[], byte[], String> encrypted = key.encryptAsync(CEK, null, null, Rsa15.ALGORITHM_NAME).get(); byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert assertEquals(Rsa15.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); }
Example #13
Source File: UrlTriePrefixGrouper.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Override public boolean hasNext() { if (_retVal != null) { return true; } while (_iterator.hasNext() && _retVal == null) { Pair<String, UrlTrieNode> nextPair = _iterator.next(); UrlTrieNode nextNode = nextPair.getRight(); if (nextNode.getSize() <= _groupSize) { _retVal = Triple.of(nextPair.getLeft(), GoogleWebmasterFilter.FilterOperator.CONTAINS, nextNode); return true; } else if (nextNode.isExist()) { _retVal = Triple.of(nextPair.getLeft(), GoogleWebmasterFilter.FilterOperator.EQUALS, nextNode); return true; } } return false; }
Example #14
Source File: PlaceDAOImpl.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override public Stream<Triple<UUID, UUID, ServiceLevel>> streamPlaceAndAccountAndServiceLevelByPartitionId(int partitionId) { try(Context ctxt = streamPlaceAndAccountAndServiceLevelByPartitionIdTimer.time()) { BoundStatement bs = streamPlaceAndAccountAndServiceLevelByPartitionId.bind(partitionId); //bs.setConsistencyLevel(ConsistencyLevel.LOCAL_ONE); ResultSet rs = session.execute(bs); return stream(rs, (row) -> { ServiceLevel s = ServiceLevel.BASIC; String fromDb = row.getString(PlaceEntityColumns.SERVICE_LEVEL); if(StringUtils.isNotBlank(fromDb)) { s = ServiceLevel.valueOf(fromDb); } return new ImmutableTriple<>(row.getUUID(BaseEntityColumns.ID), row.getUUID(PlaceEntityColumns.ACCOUNT_ID), s); }); } }
Example #15
Source File: MariadbDialect.java From sqlg with MIT License | 6 votes |
@Override public List<Triple<String, String, String>> getVertexTables(DatabaseMetaData metaData) { List<Triple<String, String, String>> vertexTables = new ArrayList<>(); String[] types = new String[]{"TABLE"}; try { //load the vertices try (ResultSet vertexRs = metaData.getTables(null, null, "V_%", types)) { while (vertexRs.next()) { //MariaDb does not support schemas. String tblCat = null; String schema = vertexRs.getString(1); String table = vertexRs.getString(3); //verify the table name matches our pattern if (!table.startsWith("V_")) { continue; } vertexTables.add(Triple.of(tblCat, schema, table)); } } } catch (SQLException e) { throw new RuntimeException(e); } return vertexTables; }
Example #16
Source File: ResourceRowLockHelper.java From dts with Apache License 2.0 | 6 votes |
private static Triple<Long, Long, String> query(final Connection connection, final String tableName, final Object rowKey) throws SQLException { PreparedStatement pstmt = null; try { pstmt = connection.prepareStatement(SELECT_SQL); pstmt.setString(1, tableName); pstmt.setObject(2, rowKey); ResultSet resultSet = pstmt.executeQuery(); Triple<Long, Long, String> triple = null; while (resultSet.next()) { Long lockedBranchId = resultSet.getLong("branch_id"); Long lockedTransId = resultSet.getLong("trans_id"); String lockedInstanceId = resultSet.getString("instance_id"); triple = new MutableTriple<Long, Long, String>(lockedBranchId, lockedTransId, lockedInstanceId); } return triple; } catch (SQLException e) { throw e; } finally { if (pstmt != null) pstmt.close(); } }
Example #17
Source File: NotificationManager.java From alf.io with GNU General Public License v3.0 | 6 votes |
private static Function<Map<String, String>, byte[]> receiptOrInvoiceFactory(EventRepository eventRepository, Function<Triple<Event, Locale, Map<String, Object>>, Optional<byte[]>> pdfGenerator) { return model -> { String reservationId = model.get("reservationId"); Event event = eventRepository.findById(Integer.valueOf(model.get("eventId"), 10)); Locale language = Json.fromJson(model.get("language"), Locale.class); Map<String, Object> reservationEmailModel = Json.fromJson(model.get("reservationEmailModel"), new TypeReference<>() { }); //FIXME hack: reservationEmailModel should be a minimal and typed container reservationEmailModel.put("event", event); Optional<byte[]> receipt = pdfGenerator.apply(Triple.of(event, language, reservationEmailModel)); if(receipt.isEmpty()) { log.warn("was not able to generate the receipt for reservation id " + reservationId + " for locale " + language); } return receipt.orElse(null); }; }
Example #18
Source File: SqlgGraph.java From sqlg with MIT License | 6 votes |
private SqlgVertex internalStreamVertex(Object... keyValues) { Preconditions.checkState(this.sqlDialect.supportsStreamingBatchMode(), "Streaming batch mode is not supported."); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label); SchemaTable streamingBatchModeVertexSchemaTable = this.tx().getBatchManager().getStreamingBatchModeVertexSchemaTable(); if (streamingBatchModeVertexSchemaTable != null && !streamingBatchModeVertexSchemaTable.toString().equals(schemaTablePair.toString())) { throw new IllegalStateException("Streaming batch mode must occur for one label at a time. Expected \"" + streamingBatchModeVertexSchemaTable + "\" found \"" + label + "\". First commit the transaction or call SqlgGraph.flush() before streaming a different label"); } List<String> keys = this.tx().getBatchManager().getStreamingBatchModeVertexKeys(); Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues, keys); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); this.tx().readWrite(); this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); return new SqlgVertex(this, false, true, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); }
Example #19
Source File: BaseSqlDialect.java From sqlg with MIT License | 6 votes |
@Override public List<Triple<String, String, String>> getVertexTables(DatabaseMetaData metaData) { List<Triple<String, String, String>> vertexTables = new ArrayList<>(); String[] types = new String[]{"TABLE"}; try { //load the vertices try (ResultSet vertexRs = metaData.getTables(null, null, Topology.VERTEX_PREFIX + "%", types)) { while (vertexRs.next()) { String tblCat = vertexRs.getString(1); String schema = vertexRs.getString(2); String table = vertexRs.getString(3); //verify the table name matches our pattern if (!table.startsWith(Topology.VERTEX_PREFIX)) { continue; } vertexTables.add(Triple.of(tblCat, schema, table)); } } } catch (SQLException e) { throw new RuntimeException(e); } return vertexTables; }
Example #20
Source File: KeyVaultKey.java From azure-keyvault-java with MIT License | 5 votes |
@Override public ListenableFuture<Triple<byte[], byte[], String>> encryptAsync(byte[] plaintext, byte[] iv, byte[] authenticationData, String algorithm) throws NoSuchAlgorithmException { if (implementation == null) { return null; } return implementation.encryptAsync(plaintext, iv, authenticationData, algorithm); }
Example #21
Source File: UsingHelper.java From cqf-ruler with Apache License 2.0 | 5 votes |
public static List<Triple<String,String,String>> getUsingUrlAndVersion(Usings usings) { if (usings == null || usings.getDef() == null) { return Collections.emptyList(); } List<Triple<String,String,String>> usingDefs = new ArrayList<>(); for (UsingDef def : usings.getDef()) { if (def.getLocalIdentifier().equals("System")) continue; usingDefs.add(Triple.of(def.getLocalIdentifier(), def.getVersion(), urlsByModelName.get(def.getLocalIdentifier()))); } return usingDefs; }
Example #22
Source File: MariadbDialect.java From sqlg with MIT License | 5 votes |
@Override public PropertyType sqlArrayTypeNameToPropertyType(String typeName, SqlgGraph sqlgGraph, String schema, String table, String columnName, ListIterator<Triple<String, Integer, String>> metaDataIter) { switch (typeName) { case "BOOLEAN ARRAY": return PropertyType.BOOLEAN_ARRAY; case "SMALLINT ARRAY": return PropertyType.SHORT_ARRAY; case "INTEGER ARRAY": return PropertyType.INTEGER_ARRAY; case "BIGINT ARRAY": return PropertyType.LONG_ARRAY; case "DOUBLE ARRAY": return PropertyType.DOUBLE_ARRAY; case "DATE ARRAY": return PropertyType.LOCALDATE_ARRAY; case "TIME WITH TIME ZONE ARRAY": return PropertyType.LOCALTIME_ARRAY; case "TIMESTAMP WITH TIME ZONE ARRAY": //need to check the next column to know if its a LocalDateTime or ZonedDateTime array Triple<String, Integer, String> metaData = metaDataIter.next(); metaDataIter.previous(); if (metaData.getLeft().startsWith(columnName + "~~~")) { return PropertyType.ZONEDDATETIME_ARRAY; } else { return PropertyType.LOCALDATETIME_ARRAY; } default: if (typeName.contains("VARCHAR") && typeName.contains("ARRAY")) { return PropertyType.STRING_ARRAY; } else { throw new RuntimeException(String.format("Array type not supported typeName = %s", typeName)); } } }
Example #23
Source File: EntitySetInvocationHandler.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC execute(final Class<SEC> collTypeRef) { final Class<S> ref = (Class<S>) ClassUtils.extractTypeArg(collTypeRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); final Class<S> oref = (Class<S>) ClassUtils.extractTypeArg(this.collItemRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); if (!oref.equals(ref)) { uri.appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(ref), ClassUtils.getEntityTypeName(ref)).toString()); } final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>(); final Triple<List<T>, URI, List<ClientAnnotation>> entitySet = fetchPartial(uri.build(), (Class<T>) ref); anns.addAll(entitySet.getRight()); final EntityCollectionInvocationHandler<S> entityCollectionHandler = new EntityCollectionInvocationHandler<S>( service, (List<S>) entitySet.getLeft(), collTypeRef, this.baseURI, uri); entityCollectionHandler.setAnnotations(anns); entityCollectionHandler.nextPageURI = entitySet.getMiddle(); return (SEC) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class<?>[] {collTypeRef}, entityCollectionHandler); }
Example #24
Source File: TicketReservationManager.java From alf.io with GNU General Public License v3.0 | 5 votes |
public Optional<Triple<Event, TicketReservation, Ticket>> from(String eventName, String reservationId, String ticketIdentifier) { return eventRepository.findOptionalByShortName(eventName).flatMap(event -> ticketReservationRepository.findOptionalReservationById(reservationId).flatMap(reservation -> ticketRepository.findOptionalByUUID(ticketIdentifier).flatMap(ticket -> Optional.of(Triple.of(event, reservation, ticket))))) .filter(x -> { Ticket t = x.getRight(); Event e = x.getLeft(); TicketReservation tr = x.getMiddle(); return tr.getId().equals(t.getTicketsReservationId()) && e.getId() == t.getEventId(); }); }
Example #25
Source File: SAFA.java From symbolicautomata with Apache License 2.0 | 5 votes |
/** * Computes the intersection with <code>aut1</code> and <code>aut2</code> as * a new SFA * @throws TimeoutException */ public static <A, B> Triple<SAFA<A, B>, PositiveBooleanExpression,PositiveBooleanExpression> binaryOp(SAFA<A, B> aut1, SAFA<A, B> aut2, BooleanAlgebra<A, B> ba, BoolOp op) throws TimeoutException { int offset = aut1.maxStateId + 1; BooleanExpressionFactory<PositiveBooleanExpression> boolexpr = getBooleanExpressionFactory(); // Integer initialState = aut1.maxStateId + aut2.maxStateId + 2; PositiveBooleanExpression initialState = null; Collection<Integer> finalStates = new ArrayList<Integer>(aut1.finalStates); for (int state : aut2.finalStates) finalStates.add(state + offset); // Copy all transitions (with proper renaming for aut2) Collection<SAFAInputMove<A, B>> transitions = new ArrayList<SAFAInputMove<A, B>>(aut1.getInputMoves()); for (SAFAInputMove<A, B> t : aut2.getInputMoves()) transitions.add(new SAFAInputMove<>(t.from + offset, boolexpr.offset(offset).apply(t.to), t.guard)); PositiveBooleanExpression liftedAut2Init = boolexpr.offset(offset).apply(aut2.initialState); switch (op) { case Union: initialState = boolexpr.MkOr(aut1.initialState, liftedAut2Init); break; case Intersection: // Add extra moves from new initial state initialState = boolexpr.MkAnd(aut1.initialState, liftedAut2Init); break; default: throw new NotImplementedException("Operation " + op + " not implemented"); } return Triple.of( MkSAFA(transitions, initialState, finalStates, ba, false, false, false), aut1.initialState, liftedAut2Init); }
Example #26
Source File: SQLServerEdgeCacheBulkRecord.java From sqlg with MIT License | 5 votes |
@Override public boolean next() { if (this.rowIter.hasNext()) { Map.Entry<SqlgEdge, Triple<SqlgVertex, SqlgVertex, Map<String, Object>>> entry = this.rowIter.next(); this.currentRow = entry.getValue(); return true; } else { return false; } }
Example #27
Source File: ConsulRegistryRepository.java From saluki with Apache License 2.0 | 5 votes |
private Triple<String, String, String> getPortHostService(String serviceId) { String[] args = StringUtils.split(serviceId, "-"); String hostRpcPort = args[0]; String service = args[1]; String version = "1.0.0"; if (args.length > 2) { version = args[2]; } return new ImmutableTriple<String, String, String>(hostRpcPort, service, version); }
Example #28
Source File: UrlTriePrefixGrouperTest.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Test public void testGroupToPagesWithContainsOperator2() { List<String> pages = Arrays.asList(_property + "13", _property + "14", _property + "1", _property + "1"); UrlTrie trie = new UrlTrie(_property, pages); ArrayList<String> actual = UrlTriePrefixGrouper.groupToPages(Triple.of(_property, FilterOperator.CONTAINS, trie.getRoot())); Assert.assertEquals(actual.toArray(), new String[]{_property + "13", _property + "14", _property + "1"}); }
Example #29
Source File: ConsulRegistryService.java From saluki with Apache License 2.0 | 5 votes |
private Set<String> buildQueryCondition(String search, String dimension, Boolean accurate) { Set<String> beAboutToQuery = Sets.newHashSet(); Map<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> servicesPassing = registryRepository.getAllPassingService(); for (Map.Entry<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> entry : servicesPassing.entrySet()) { String serviceKey = entry.getKey(); Triple<String, String, String> appNameServiceVersion = getAppNameServiceVersion(serviceKey); String appName = appNameServiceVersion.getLeft(); String serviceName = appNameServiceVersion.getMiddle(); if (dimension.equals("service")) { if (accurate) { if (StringUtils.equalsIgnoreCase(serviceName, search)) { beAboutToQuery.add(serviceKey); } } else { if (StringUtils.containsIgnoreCase(serviceName, search)) { beAboutToQuery.add(serviceKey); } } } else { if (accurate) { if (StringUtils.equalsIgnoreCase(appName, search)) { beAboutToQuery.add(serviceKey); } } else { if (StringUtils.containsIgnoreCase(appName, search)) { beAboutToQuery.add(serviceKey); } } } } return beAboutToQuery; }
Example #30
Source File: ConsulRegistryService.java From saluki with Apache License 2.0 | 5 votes |
private List<GrpcService> buildQueryResponse(Set<String> queryCondition, Boolean accurate) { List<GrpcService> services = Lists.newArrayList(); Map<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> servicesPassing = registryRepository.getAllPassingService(); for (Iterator<String> it = queryCondition.iterator(); it.hasNext();) { String serviceKey = it.next(); Triple<String, String, String> appNameServiceVersion = getAppNameServiceVersion(serviceKey); Pair<Set<GrpcHost>, Set<GrpcHost>> providerConsumer = servicesPassing.get(serviceKey); GrpcService service = new GrpcService(appNameServiceVersion.getLeft(), appNameServiceVersion.getRight(), appNameServiceVersion.getMiddle()); service.setProviderHost(providerConsumer.getLeft()); service.setConsumerHost(providerConsumer.getRight()); services.add(service); } return services; }