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.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 a va2 s.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:com.nttec.everychan.ui.gallery.GalleryInitResult.java
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(initPosition);/*from w w w. j av a 2s . co m*/ dest.writeInt(shouldWaitForPageLoaded ? 1 : 0); dest.writeInt(attachments.size()); for (Triple<AttachmentModel, String, String> tuple : attachments) { AttachmentModel attachment = tuple.getLeft(); dest.writeInt(attachment.type); dest.writeInt(attachment.size); dest.writeString(attachment.thumbnail); dest.writeString(attachment.path); dest.writeInt(attachment.width); dest.writeInt(attachment.height); dest.writeString(attachment.originalName); dest.writeInt(attachment.isSpoiler ? 1 : 0); dest.writeString(tuple.getMiddle()); dest.writeString(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 w w w . j av a 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:com.quartercode.jtimber.rh.agent.asm.InsertJAXBTweaksClassAdapter.java
private void generateAfterUnmarshalMethod(Method method) { GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, method, null, null, cv); /*/*from w w w. j a va 2s .c om*/ * Iterate through all fields annotated with "SubstituteWithWrapper" and replace their current value with their current value wrapped inside a wrapper. * This section first reads the current field value, then creates a new wrapper which wraps around that field value, and finally sets the field to the wrapper. */ for (Triple<String, Type, Type> field : fieldsForWrapperSubstitution) { String fieldName = field.getLeft(); Type fieldType = fields.get(fieldName); Type wrapperType = field.getMiddle(); // Null means "default"; in that case, the field type is used as the type of the first argument of the wrapper constructor Type wrapperConstructorArgType = field.getRight() == null ? fieldType : field.getRight(); // Note that this reference will be used for the PUTFIELD instruction later on mg.loadThis(); // ----- Stack: [this] // Creates the wrapper using the current field value { // Create a new instance of the wrapper type and duplicate it for the constructor call later on mg.newInstance(wrapperType); mg.dup(); // ----- Stack: [this, wrapper, wrapper] // Retrieve the current field value ASMUtils.generateGetField(mg, classType, fieldName, fieldType); // ----- Stack: [this, wrapper, wrapper, fieldValue] // Call the constructor of the new wrapper using the current field value as the first argument mg.invokeConstructor(wrapperType, Method.getMethod("void <init> (" + wrapperConstructorArgType.getClassName() + ")")); // ----- Stack: [this, wrapper] } // Store the new wrapper in the field the value has been retrieved from before // The substitution is complete mg.putField(classType, fieldName, fieldType); // ----- Stack: [] } /* * Iterate through all fields. * For each field, call the addParent() method with "this" as parent if the current field value is parent-aware */ for (Entry<String, Type> field : fields.entrySet()) { String fieldName = field.getKey(); Type fieldType = field.getValue(); ASMUtils.generateGetField(mg, classType, fieldName, fieldType); // ----- Stack: [fieldValue] ASMUtils.generateAddOrRemoveThisAsParent(mg, "addParent"); } // End the method mg.returnValue(); mg.endMethod(); }
From source file:de.pixida.logtest.reporting.XUnitReportGenerator.java
private void addTestCases(final Document doc, final Element rootElement) { for (final Entry<Job, List<Triple<LogSink, EvaluationResult, Long>>> resultSet : this.results.entrySet()) { // The class name usually includes its packet name which is displayed as tree in Jenkins. // This might lead to the following tree hierarchy: "some-log" -> "txt" -> ..results.. // "some-other-log" -> "txt" -> ..results.. // Furthermore, we down't know how the log source is represented as human readable string, so it may always contain // dots, e.g. "127.0.0.1:8082" for stream sources. // For now, replace all dots by a "-", such that the human readable identifier of the log source remains human readable and // all information is preserved. String className = resultSet.getKey().getLogReader().getDisplayName(); className = className.replace('.', '-'); for (final Triple<LogSink, EvaluationResult, Long> result : resultSet.getValue()) { final String testcaseName = result.getLeft().getDisplayName(); final Element testcase = doc.createElement("testcase"); testcase.setAttribute("classname", className); testcase.setAttribute("name", testcaseName); // Actually, set the job time, not the test time (tests run in parallel). The attribute is mandatory. final long msToSec = 1000; testcase.setAttribute("time", String.valueOf((double) result.getRight() / msToSec)); if (!result.getMiddle().isSuccess()) { final Element error = doc.createElement(result.getMiddle().isError() ? "error" : "failure"); assert result.getMiddle().getMessage() != null; error.setAttribute("type", result.getMiddle().getResult().toString()); error.setAttribute("message", result.getMiddle().getMessage()); testcase.appendChild(error); }//from w w w . jav a2 s.com rootElement.appendChild(testcase); } } }
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 ww. j av a2 s .c o m 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:io.lavagna.service.EventEmitter.java
private void sendEventForLabel(List<CardFull> affectedCards, LavagnaEvent ev) { Triple<Set<Integer>, Set<Integer>, Set<String>> a = extractFrom(affectedCards); for (int cardId : a.getLeft()) { messagingTemplate.convertAndSend(cardData(cardId), event(ev)); }//from w w w . j a v a2 s . c o m for (int columnId : a.getMiddle()) { messagingTemplate.convertAndSend(column(columnId), event(ev)); } for (String projectShortName : a.getRight()) { messagingTemplate.convertAndSend("/event/project/" + projectShortName + "/label-value", event(ev)); } }
From source file:com.hurence.logisland.processor.datastore.EnrichRecords.java
/** * process events/*from w w w . j av a 2 s . c o m*/ * * @param context * @param records * @return */ @Override public Collection<Record> process(final ProcessContext context, final Collection<Record> records) { List<Record> outputRecords = new ArrayList<>(); List<Triple<Record, String, IncludeFields>> recordsToEnrich = new ArrayList<>(); if (records.size() != 0) { String excludesFieldName = context.getPropertyValue(EXCLUDES_FIELD).asString(); // Excludes : String[] excludesArray = null; if ((excludesFieldName != null) && (!excludesFieldName.isEmpty())) { excludesArray = excludesFieldName.split("\\s*,\\s*"); } //List<MultiGetQueryRecord> multiGetQueryRecords = new ArrayList<>(); MultiGetQueryRecordBuilder mgqrBuilder = new MultiGetQueryRecordBuilder(); mgqrBuilder.excludeFields(excludesArray); List<MultiGetResponseRecord> multiGetResponseRecords = null; // HashSet<String> ids = new HashSet<>(); // Use a Set to avoid duplicates for (Record record : records) { String recordKeyName = null; String indexName = null; String typeName = FieldDictionary.RECORD_TYPE; String includesFieldName = null; try { recordKeyName = context.getPropertyValue(RECORD_KEY_FIELD).evaluate(record).asString(); indexName = context.getPropertyValue(COLLECTION_NAME).evaluate(record).asString(); if (context.getPropertyValue(TYPE_NAME).isSet()) typeName = context.getPropertyValue(TYPE_NAME).evaluate(record).asString(); includesFieldName = context.getPropertyValue(INCLUDES_FIELD).evaluate(record).asString(); } catch (Throwable t) { record.setStringField(FieldDictionary.RECORD_ERRORS, "Failure in executing EL. Error: " + t.getMessage()); getLogger().error("Cannot interpret EL : " + record, t); } if (recordKeyName != null) { try { String key = record.getField(recordKeyName).asString(); // Includes : String[] includesArray = null; if ((includesFieldName != null) && (!includesFieldName.isEmpty())) { includesArray = includesFieldName.split("\\s*,\\s*"); } IncludeFields includeFields = new IncludeFields(includesArray); mgqrBuilder.add(indexName, typeName, includeFields.getAttrsToIncludeArray(), key); recordsToEnrich.add( new ImmutableTriple(record, asUniqueKey(indexName, typeName, key), includeFields)); } catch (Throwable t) { record.setStringField(FieldDictionary.RECORD_ERRORS, "Can not request datastore with " + indexName + " " + typeName + " " + recordKeyName); outputRecords.add(record); } } else { //record.setStringField(FieldDictionary.RECORD_ERRORS, "Interpreted EL returned null for recordKeyName"); outputRecords.add(record); //logger.error("Interpreted EL returned null for recordKeyName"); } } try { List<MultiGetQueryRecord> mgqrs = mgqrBuilder.build(); multiGetResponseRecords = datastoreClientService.multiGet(mgqrs); } catch (InvalidMultiGetQueryRecordException e) { getLogger().error("error while multiger", e); } if (multiGetResponseRecords == null || multiGetResponseRecords.isEmpty()) { return records; } // Transform the returned documents from ES in a Map Map<String, MultiGetResponseRecord> responses = multiGetResponseRecords.stream() .collect(Collectors.toMap(EnrichRecords::asUniqueKey, Function.identity())); recordsToEnrich.forEach(recordToEnrich -> { Triple<Record, String, IncludeFields> triple = recordToEnrich; Record outputRecord = triple.getLeft(); // TODO: should probably store the resulting recordKeyName during previous invocation above String key = triple.getMiddle(); IncludeFields includeFields = triple.getRight(); MultiGetResponseRecord responseRecord = responses.get(key); if ((responseRecord != null) && (responseRecord.getRetrievedFields() != null)) { // Retrieve the fields from responseRecord that matches the ones in the recordToEnrich. responseRecord.getRetrievedFields().forEach((k, v) -> { String fieldName = k.toString(); if (includeFields.includes(fieldName)) { // Now check if there is an attribute mapping rule to apply if (includeFields.hasMappingFor(fieldName)) { String mappedAttributeName = includeFields.getAttributeToMap(fieldName); // Replace the attribute name outputRecord.setStringField(mappedAttributeName, v.toString()); } else { outputRecord.setStringField(fieldName, v.toString()); } } }); } outputRecords.add(outputRecord); }); } return outputRecords; }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateLibrariesPanel.java
public void initialize() { PlatformUI.MIRTH_FRAME.codeTemplatePanel.doRefreshCodeTemplates(new ActionListener() { @Override/*from w w w .jav a 2s. c o m*/ public void actionPerformed(ActionEvent evt) { for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel .getCachedCodeTemplateLibraries().values()) { libraryMap.put(library.getId(), new CodeTemplateLibrary(library)); } Map<String, CodeTemplate> codeTemplateMap = PlatformUI.MIRTH_FRAME.codeTemplatePanel .getCachedCodeTemplates(); DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(); for (CodeTemplateLibrary library : libraryMap.values()) { boolean enabled = library.getEnabledChannelIds().contains(channelId) || (library.isIncludeNewChannels() && !library.getDisabledChannelIds().contains(channelId)); DefaultMutableTreeTableNode libraryNode = new DefaultMutableTreeTableNode( new ImmutableTriple<String, String, Boolean>(library.getId(), library.getName(), enabled)); for (CodeTemplate codeTemplate : library.getCodeTemplates()) { codeTemplate = codeTemplateMap.get(codeTemplate.getId()); if (codeTemplate != null) { libraryNode.add( new DefaultMutableTreeTableNode(new ImmutableTriple<String, String, Boolean>( codeTemplate.getId(), codeTemplate.getName(), enabled))); } } rootNode.add(libraryNode); } ((DefaultTreeTableModel) libraryTreeTable.getTreeTableModel()).setRoot(rootNode); libraryTreeTable.expandAll(); libraryTreeTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent evt) { for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((DefaultMutableTreeTableNode) libraryTreeTable .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) { Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNodes .nextElement().getUserObject(); CodeTemplateLibrary library = libraryMap.get(triple.getLeft()); if (triple.getRight()) { library.getDisabledChannelIds().remove(channelId); library.getEnabledChannelIds().add(channelId); } else { library.getDisabledChannelIds().add(channelId); library.getEnabledChannelIds().remove(channelId); } } } }); parent.codeTemplateLibrariesReady(); } }); }
From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToIntTriFunction.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 a va 2 s .co m default int applyAsIntThrows(@Nonnull Triple<T, U, V> tuple) throws X { Objects.requireNonNull(tuple); return applyAsIntThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight()); }