List of usage examples for java.util List equals
boolean equals(Object o);
From source file:com.github.htfv.maven.plugins.buildconfigurator.core.utils.MergeUtilsTest.java
@Test public void test1() { final List<String> target = Arrays.asList("A", "B", "D", "X", "E", "Y"); final List<String> source = Arrays.asList("A", "C", "D", "Y", "F", "X"); final List<String> result = Arrays.asList("A", "B", "C", "D", "F", "X", "E", "Y"); final List<String> targetList = new ArrayList<String>(target); MergeUtils.mergeCollections(targetList, source, new MergeUtils.MergeHelper<String, String>() { @Override/* www . jav a2 s . com*/ public String add(final String right) { return right; } @Override public boolean equals(final String left, final String right) { return ObjectUtils.equals(left, right); } @Override public String update(final String left, final String right) { return left; } }); assertTrue(targetList.equals(result)); }
From source file:com.unister.semweb.drums.file.EnlargeFileTest.java
/** * The test data don't fit into the increment so a the file must be enlarged. After writing a bunch of test data * that are greater in size that the increment size another huge bunch will be written. This simulates a problem * that we have encountered when the enlargement is not done correctly. *///from w w w .j av a 2 s.co m @Test public void bigEnlargment() throws Exception { DRUMSParameterSet<TestStorable> globalParameters = new DRUMSParameterSet<TestStorable>(new TestStorable()); globalParameters.INITIAL_INCREMENT_SIZE = 1000; globalParameters.INITIAL_FILE_SIZE = HeaderIndexFile.HEADER_SIZE; List<TestStorable> testdata = generateTestdata(50000); List<TestStorable> testdata2 = generateTestdata(20000); List<TestStorable> overallTestdata = new ArrayList<TestStorable>(testdata); overallTestdata.addAll(testdata2); List<Long> filePositions = writeData(testdata, globalParameters); List<Long> secondFilePositions = writeData(testdata2, globalParameters); List<Long> overallFilePositions = new ArrayList<Long>(filePositions); overallFilePositions.addAll(secondFilePositions); List<TestStorable> readData = readFile(overallFilePositions, globalParameters); Assert.assertTrue(overallTestdata.equals(readData)); }
From source file:com.unister.semweb.drums.file.EnlargeFileTest.java
@Test public void specialTest() throws Exception { DRUMSParameterSet<TestStorable> globalParameters = new DRUMSParameterSet<TestStorable>(new TestStorable()); globalParameters.INITIAL_INCREMENT_SIZE = 50; globalParameters.INITIAL_FILE_SIZE = (int) (HeaderIndexFile.HEADER_SIZE + HeaderIndexFile.MAX_INDEX_SIZE_IN_BYTES); List<TestStorable> testdata = generateTestdata(3); List<TestStorable> testdata2 = generateTestdata(200); List<TestStorable> overallTestdata = new ArrayList<TestStorable>(testdata); overallTestdata.addAll(testdata2);/*from w ww . j a va 2 s .c om*/ List<Long> filePositions = writeData(testdata, globalParameters); List<Long> secondFilePositions = writeData(testdata2, globalParameters); List<Long> overallFilePositions = new ArrayList<Long>(filePositions); overallFilePositions.addAll(secondFilePositions); List<TestStorable> readData = readFile(overallFilePositions, globalParameters); Assert.assertTrue(overallTestdata.equals(readData)); }
From source file:com.dlshouwen.jspc.zjpc.controller.ExpreviewController.java
private String getItemForHtml(List<EvalItem> items, ServletContext sc) { String result = "", preHtml, sufHtml; sufHtml = "</tr>" + "</table>" + "</div>" + "</li>"; if (!items.equals(null) && items.size() > 0) { for (int i = 0; i < items.size(); i++) { preHtml = "<li class='item-table-list-li'>" + "<div class='item-table-list-box'>" // + "<i class='fa fa-edit' style='display:none;' onclick=\"editItem('"+items.get(i).getEvalItem_id()+"','"+items.get(i).getType()+"')\"></i>" // + "<i class='fa fa-times' style='display:none;' id='"+items.get(i).getEvalItem_id()+"' onclick=\"deleteItem('"+items.get(i).getEvalItem_id()+"')\"></i>" + "<table class='table table-responsive item-table-list' width='100%' border='0' cellspacing='0' cellpadding='0'>" + "<tr>"; String bDate = DateUtils.getYearMonth(items.get(i).getBeginDate()); String eDate = DateUtils.getYearMonth(items.get(i).getEndDate()); String level = CodeTableUtils.getValue(sc, "ryjb", items.get(i).getLevel()); String grade = CodeTableUtils.getValue(sc, "hjdj", items.get(i).getGrade()); level = StringUtils.isEmpty(level) ? "" : level; grade = StringUtils.isEmpty(grade) ? "" : grade; result += preHtml;//from w w w . j ava 2 s . co m result += "<td class='first_td'>" + bDate + "-" + eDate + "</td>"; result += "<td>" + items.get(i).getName() + "</td>"; result += "<td>" + level + grade + "</td>"; result += "<td><a href='" + sc.getContextPath() + "/jspc/zwpc/zwpc/downloadFile?itemId=" + items.get(i).getEvalItem_id() + "' class='table-tc-fj-open' ></a></td>"; result += sufHtml; } } else { result = "<div class='div_zanwu'></div>"; } return result; }
From source file:org.datanucleus.ide.idea.ui.v10x.DNEConfigFormV10x.java
public boolean isModified() { final GuiState data = this.guiState; if (this.enableEnhancerCheckBox.isSelected() != data.isEnhancerEnabled()) { return true; }/* ww w . j a v a 2 s . com*/ final String metadataExtensionTextFieldText = this.metadataExtensionTextField.getText(); if (metadataExtensionTextFieldText != null ? !metadataExtensionTextFieldText.trim().equals(data.getMetaDataExtensions()) && !containsDisabledTokens(metadataExtensionTextFieldText) : data.getMetaDataExtensions() != null && !data.getMetaDataExtensions().trim().isEmpty()) { return true; } if (this.addToCompilerResourceCheckBox.isSelected() != data.isAddToCompilerResourcePatterns()) { return true; } if (this.includeTestClassesCheckBox.isSelected() != data.isIncludeTestClasses()) { return true; } if (!this.jDORadioButton.isSelected() && PersistenceApi.JDO == data.getApi()) { return true; } if (!this.jPARadioButton.isSelected() && PersistenceApi.JPA == data.getApi()) { return true; } final EnhancerSupport enhancerSupport = getByEnhancerSupportName(data, (String) this.persistenceImplComboBox.getSelectedItem()); if (!data.getEnhancerSupport().getId().equals(enhancerSupport.getId())) { return true; } final PersistenceApi selectedApi = this.jDORadioButton.isSelected() ? PersistenceApi.JDO : PersistenceApi.JPA; if (data.getApi() != selectedApi) { return true; } final AffectedModulesRowModel affectedModulesRowModel = (AffectedModulesRowModel) this.affectedModulesTable .getModel(); final List<AffectedModule> affectedModules = affectedModulesRowModel.getAffectedModules(); return affectedModules != null ? !affectedModules.equals(data.getAffectedModules()) : data.getAffectedModules() != null; }
From source file:org.kuali.rice.krad.web.controller.helper.DataTablesPagingHelper.java
/** * Sort the given modelCollection (in place) according to the specified columnSorts. * * <p>Not all columns will necessarily be directly mapped to the modelCollection, so the collectionGroup and view * are available as well for use in calculating those other column values. However, if all the columns are in fact * mapped to the elements of the modelCollection, subclasses should be able to easily override this method to * provide custom sorting logic.</p> * * <p>//from w w w. j ava 2s . c o m * Create an index array and sort that. The array slots represents the slots in the modelCollection, and * the values are indices to the elements in the modelCollection. At the end, we'll re-order the * modelCollection so that the elements are in the collection slots that correspond to the array locations. * * A small example may be in order. Here's the incoming modelCollection: * * modelCollection = { "Washington, George", "Adams, John", "Jefferson, Thomas", "Madison, James" } * * Initialize the array with its element references all matching initial positions in the modelCollection: * * reSortIndices = { 0, 1, 2, 3 } * * After doing our sort in the array (where we sort indices based on the values in the modelCollection): * * reSortIndices = { 1, 2, 3, 0 } * * Then, we go back and apply that ordering to the modelCollection: * * modelCollection = { "Adams, John", "Jefferson, Thomas", "Madison, James", "Washington, George" } * * Why do it this way instead of just sorting the modelCollection directly? Because we may need to know * the original index of the element e.g. for the auto sequence column. * </p> * * @param modelCollection the collection to sort * @param oldColumnSorts the sorting that reflects the current state of the collection * @param newColumnSorts the sorting to apply to the collection * @param collectionGroup the CollectionGroup that is being rendered * @param view the view */ protected void applyTableJsonSort(List<Object> modelCollection, List<ColumnSort> oldColumnSorts, List<ColumnSort> newColumnSorts, CollectionGroup collectionGroup, View view) { boolean isCollectionEmpty = CollectionUtils.isEmpty(modelCollection); boolean isSortingSpecified = !CollectionUtils.isEmpty(newColumnSorts); boolean isSortOrderChanged = newColumnSorts != oldColumnSorts && !newColumnSorts.equals(oldColumnSorts); if (!isCollectionEmpty && isSortingSpecified && isSortOrderChanged) { Integer[] sortIndices = new Integer[modelCollection.size()]; for (int i = 0; i < sortIndices.length; i++) { sortIndices[i] = i; } Arrays.sort(sortIndices, new MultiColumnComparator(modelCollection, collectionGroup, newColumnSorts, view)); // apply the sort to the modelCollection Object[] sorted = new Object[sortIndices.length]; for (int i = 0; i < sortIndices.length; i++) { sorted[i] = modelCollection.get(sortIndices[i]); } for (int i = 0; i < sorted.length; i++) { modelCollection.set(i, sorted[i]); } } }
From source file:org.nuxeo.ecm.platform.faceted.search.jsf.FacetedSearchActions.java
/** * @throws ClientException// w w w. j ava 2 s. c om * @since 5.8 */ @Observer(value = USER_ALL_DOCUMENT_TYPES_SELECTION_CHANGED) public void invalidateContentViewsNameIfChanged() throws ClientException { List<String> temp = new ArrayList<String>(Framework.getLocalService(FacetedSearchService.class) .getContentViewNames(navigationContext.getCurrentDocument())); if (temp != null) { if (!temp.equals(contentViewNames)) { invalidateContentViewsName(); } } }
From source file:com.collabnet.ccf.pi.qc.QCReaderOutputVerificator.java
@SuppressWarnings("unchecked") public Object[] processXMLDocuments(Object data, String fileName) { int runStatus = 1; List<String> failure = new ArrayList<String>(); List<String> success = new ArrayList<String>(); String passStatus = "Run Passed"; success.add(passStatus);//from www . j a v a 2 s . c o m String failStatus = "Run Failed"; failure.add(failStatus); List<Document> incomingDocumentList = (List<Document>) data; try { FileInputStream in = new FileInputStream(fileName); ObjectInputStream s = new ObjectInputStream(in); PrintWriter out1 = new PrintWriter(new FileWriter("inDoc.xml")); PrintWriter out2 = new PrintWriter(new FileWriter("retDoc.xml")); List<List<Document>> retObj = (List<List<Document>>) s.readObject(); List<Document> retrievedDocumentList = (List<Document>) retObj.get(0); if (incomingDocumentList.equals((List<Document>) retrievedDocumentList)) return success.toArray(); int retrievedSize = retrievedDocumentList.size(); int incomingSize = incomingDocumentList.size(); if (retrievedSize != incomingSize) return failure.toArray(); for (int cnt = 0; cnt < retrievedSize; cnt++) { Document inDoc = incomingDocumentList.get(cnt); Document retDoc = retrievedDocumentList.get(cnt); String inRecord = inDoc.asXML(); String retRecord = retDoc.asXML(); //inDoc. if (inRecord.equals(retRecord)) runStatus = 1; else runStatus = 0; out1.write(inDoc.asXML()); out2.write(retDoc.asXML()); } } catch (IOException e) { System.out.println("File handling exception" + e); } catch (ClassNotFoundException e) { System.out.println("Class not found exception" + e); } if (runStatus == 0) return failure.toArray(); return success.toArray(); }
From source file:org.openhie.openempi.openpixpdqadapter.PixManagerAdapter.java
public List<List<PatientIdentifier>> updatePatient(Patient patient, MessageHeader messageHeader) throws PixManagerException { List<List<PatientIdentifier>> ret = new ArrayList<List<PatientIdentifier>>(); Person person = ConversionHelper.getPerson(patient); PatientIdentifier patientId = patient.getPatientIds().get(0); List<PatientIdentifier> oldMatching = findPatientIds(patientId, messageHeader); //1. find the original matching patient // TODO: Need to check that there is at least one identifier provided here but // for now the assumption is that the generic PIX code will do the validation before it forwards the // request to the adaptor. //// ww w . j a v a 2 s.c o m PersonIdentifier id = person.getPersonIdentifiers().iterator().next(); Person originalPerson; try { SecurityHelper.getSessionKey(); originalPerson = Context.getPersonQueryService().findPersonById(id); } catch (Exception e) { throw new PixManagerException(e); } if (originalPerson == null) { log.warn("Unable to find the patient to be updated using the identifier: " + id); throw new PixManagerException("Unable to find the patient to be updated in the registry."); } updatePersonAttributes(originalPerson, person); //2. Update Patient try { Context.getPersonManagerService().updatePerson(originalPerson); } catch (Exception e) { throw new PixManagerException(e); } List<PatientIdentifier> newMatching = findPatientIds(patientId, messageHeader); List<PatientIdentifier> unmatching = new ArrayList<PatientIdentifier>(); for (PatientIdentifier oldPid : oldMatching) { if (!newMatching.contains(oldPid)) { unmatching.add(oldPid); } } //If there is any update on the matching if (!newMatching.equals(oldMatching)) { //Add the original patient id since findPatientIds //does not include the original patient id. newMatching.add(patientId); ret.add(newMatching); } if (unmatching.size() > 0) { ret.add(unmatching); } return ret; }
From source file:com.frostwire.android.gui.adapters.TransferListAdapter.java
public TransferListAdapter(Context context, List<Transfer> list) { this.contextRef = new WeakReference<>(context); this.dialogs = new ArrayList<>(); this.list = list.equals(Collections.emptyList()) ? new ArrayList<>() : list; viewOnClickListener = new ViewOnClickListener(); viewOnLongClickListener = new ViewOnLongClickListener(); openOnClickListener = new OpenOnClickListener(context); transferDetailsClickListener = new TransferDetailsClickListener(context); }