List of usage examples for java.util NavigableSet add
boolean add(E e);
From source file:Main.java
public static void main(String[] args) { String[] cities = { "A", "B", "C", "D", "E", "F" }; NavigableSet<String> citiesSet = new TreeSet<String>(); for (String city : cities) citiesSet.add(city); System.out.println(citiesSet.ceiling("A")); }
From source file:Main.java
public static void main(String[] args) { String[] cities = { "A", "B", "C", "D", "E", "F" }; NavigableSet<String> citiesSet = new TreeSet<String>(); for (String city : cities) citiesSet.add(city); System.out.println(citiesSet.floor("A")); }
From source file:Main.java
public static void main(String[] args) { NavigableSet<Integer> ns = new TreeSet<>(); ns.add(0); ns.add(1);/* ww w . ja v a 2 s .co m*/ ns.add(2); ns.add(3); ns.add(4); ns.add(5); ns.add(6); // Get a reverse view of the navigable set NavigableSet<Integer> reverseNs = ns.descendingSet(); // Print the normal and reverse views System.out.println("Normal order: " + ns); System.out.println("Reverse order: " + reverseNs); NavigableSet<Integer> threeOrMore = ns.tailSet(3, true); System.out.println("3 or more: " + threeOrMore); System.out.println("lower(3): " + ns.lower(3)); System.out.println("floor(3): " + ns.floor(3)); System.out.println("higher(3): " + ns.higher(3)); System.out.println("ceiling(3): " + ns.ceiling(3)); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollLast(): " + ns.pollLast()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("pollLast(): " + ns.pollLast()); }
From source file:org.excalibur.discovery.ws.client.ClustersClient.java
public static <E> NavigableSet<E> convertValue(List<?> members, Class<E> type) { NavigableSet<E> nodes = new TreeSet<E>(); if (members != null) { for (Object member : members) { nodes.add(RESOURCE_MAPPER.convertValue(member, type)); }/*from w w w . j av a2 s. c o m*/ } return nodes; }
From source file:org.excalibur.discovery.ws.client.DiscoveryUtils.java
public static NavigableSet<NodeDetails> getMembers(List<ResourceDetails> resources) throws OverlayException { NavigableSet<NodeDetails> members = newTreeSet(); for (ResourceDetails resource : resources) { try {// w w w . j a v a 2s .c o m members.add(FACTORY.unmarshal(resource.getPayload())); } catch (JAXBException e) { throw new OverlayException(e.getMessage(), e); } } return members; }
From source file:eu.ggnet.dwoss.report.assist.ReportUtil.java
/** * Returns all Lines of the Report for Category Invoiced. * This consists of:/*from w ww. ja v a 2 s . co m*/ * <ul> * <li>Position of Type Capital Asset</li> * <li>Position of Type Invoice, with no References</li> * <li>Position of Type UNIT_ANNEX in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice in the same report.</li> * </ul> * <p> * It's not allowed to have a null value in the collection. * <p> * @param lines * @return all Lines of the Report for Category Invoiced. */ //TODO: We could also substract the value of a unitannex from the invoice and not return the unit annex at all. //But consider the impact in the ui, especially if we allow selection of such a "combined" line. public static NavigableSet<ReportLine> filterInvoiced(Collection<ReportLine> lines) { NavigableSet<ReportLine> result = new TreeSet<>(); for (ReportLine line : lines) { if (line.getDocumentType() == CAPITAL_ASSET) result.add(line); if (line.getDocumentType() == INVOICE && !line.isFullRepayedIn(lines)) result.add(line); if (line.isPartialRepayment() && !line.isFullRepayedIn(lines)) { ReportLine invoiceRef = line.getSingleReference(INVOICE); if (invoiceRef == null) /* No Invoice exists, probably before 2014 */ result.add(line); else if (lines.contains(invoiceRef)) result.add(line); } } return result; }
From source file:eu.ggnet.dwoss.report.assist.ReportUtil.java
/** * Returns all Lines of the Report for Category Invoiced, split by mfgDate - startOfReport < 1 year and the rest. * This consists of:// w ww . j a va2 s. co m * <ul> * <li>Position of Type Invoice, with no References</li> * <li>Position of Type UNIT_ANNEX in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice in the same report.</li> * </ul> * <p> * It's not allowed to have a null value in the collection. * <p> * @param lines * @param startingDate * @return all Lines of the Report for Category Invoiced. */ public static YearSplit filterInvoicedSplit(Collection<ReportLine> lines, Date startingDate) { NavigableSet<ReportLine> pastSplit = new TreeSet<>(); NavigableSet<ReportLine> preSplit = new TreeSet<>(); Date splitter = DateUtils.addYears(startingDate, -1); for (ReportLine line : filterInvoiced(lines)) { if (splitter.before(line.getMfgDate())) { preSplit.add(line); } else { pastSplit.add(line); } } return new YearSplit(startingDate, preSplit, pastSplit); }
From source file:eu.ggnet.dwoss.report.assist.ReportUtil.java
/** * Returns all Lines of the Report which represent Positions of CreditMemos and Annulation Invoices but the associated Invoices have been reported before. * This consists of:/* ww w. j a v a 2s . c o m*/ * <ul> * <li>Position of Type UNIT in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice is not in same report.</li> * <li>Position of Type UNIT_ANNEX in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice is not in same report and no UNIT also in this * report</li> * </ul> * <p> * It's not allowed to have a null value in the collection. * <p> * @param lines * @return all Lines of the Report which represent Positions of CreditMemos and Annulation Invoices but the associated Invoices have been reported before. */ public static NavigableSet<ReportLine> filterRepayed(Collection<ReportLine> lines) { NavigableSet<ReportLine> result = new TreeSet<>(); for (ReportLine line : lines) { if (line.isFullRepayment()) { ReportLine invoiceRef = line.getSingleReference(DocumentType.INVOICE); if (invoiceRef == null) /* No Invoice exists, probably before 2014 */ result.add(line); else if (!lines.contains(invoiceRef)) result.add(line); } if (line.isPartialRepayment() && !line.isFullRepayedIn(lines)) { ReportLine invoiceRef = line.getSingleReference(INVOICE); if (invoiceRef == null) /* No Invoice exists, probably before 2014 */ result.add(line); else if (!lines.contains(invoiceRef)) result.add(line); } } return result; }
From source file:eu.ggnet.dwoss.report.assist.ReportUtil.java
/** * Removes all Lines, that only represent active Info (open Complaints). * <ol>//from w ww . jav a 2 s .c om * <li>Sammle alle only Invoice Positions raus Report</li> * <li>Sammle alle Repayment Positions raus Report</li> * <li>Sammle alle Complaint Positionen die mit den Repayment Positionen zusammenhngen raus Report</li> * <li>Sammle alle Compleints die DISCHARDED sind Report</li> * <li>Alles was brig ist, sollten (offene) Complaints sein Active Info</li> * </ol> * <p> * It's not allowed to have a null value in the collection. * <p> * @param allLines all lines. * @param reportType the report type * @return */ public static PrepareReportPartition partition(Collection<ReportLine> allLines, TradeName reportType) { L.debug("filter {}", allLines); NavigableSet<ReportLine> reportAble = new TreeSet<>(); for (ReportLine line : allLines) { L.debug("filter processing {}", line.toSimple()); if (!(line.getDocumentType() == DocumentType.ANNULATION_INVOICE || line.getDocumentType() == DocumentType.CREDIT_MEMO || line.getDocumentType() == DocumentType.CAPITAL_ASSET || (line.getDocumentType() == DocumentType.COMPLAINT && line.getWorkflowStatus() == WorkflowStatus.DISCHARGED) || (line.getDocumentType() == DocumentType.INVOICE && line.hasNoRepayments()) && line.hasNoOpenComplaints())) continue; L.debug("filter processing, add to reportAble {}", line.toSimple()); reportAble.add(line); Date tomorrow = DateUtils.addDays(line.getReportingDate(), 1); for (ReportLine ref : line.getRefrences()) { if (ref.getDocumentType() == DocumentType.COMPLAINT && !ref.isInReport(reportType)) { L.debug("filter processing referencing complaints, add to reportAble {}", ref.toSimple()); reportAble.add(ref); } else if (ref.getDocumentType() == DocumentType.INVOICE && !ref.isInReport(reportType) && ref.getReportingDate().before(tomorrow)) { L.debug("filter processing referencing invoices, add to reportAble {}", ref.toSimple()); reportAble.add(ref); } } } NavigableSet<ReportLine> activeInfo = new TreeSet<>(allLines); activeInfo.removeAll(reportAble); return new PrepareReportPartition(reportAble, activeInfo); }
From source file:com.shadowmvcc.coherence.domain.DomainSerialisationTest.java
/** * TransactionSetWrapper.// www . j av a2 s . c o m */ @Test public void testTransactionSetWrapper() { TransactionSetWrapper tsw = new TransactionSetWrapper(); NavigableSet<TransactionId> ts = new TreeSet<TransactionId>(); ts.add(new TransactionId(BASETIME + 17, 124, 457)); ts.add(new TransactionId(BASETIME + 42, 124, 457)); ts.add(new TransactionId(BASETIME + 42, 124, 455)); tsw.setTransactionIdSet(ts); assertPofFidelityByReflection(tsw); }