Example usage for java.util NavigableSet add

List of usage examples for java.util NavigableSet add

Introduction

In this page you can find the example usage for java.util NavigableSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:py.una.pol.karaku.menu.server.MenuServerLogic.java

private void handleRootMenu(Menu menu) {

    // Este hashSet se usa como un queue, solamente que es deseable que no
    // tenga valores repetidos
    NavigableSet<Menu> toSort = new TreeSet<Menu>();
    Map<Menu, Menu> parents = new HashMap<Menu, Menu>();
    toSort.add(menu);
    Menu next;//from  w w  w . j  av a  2 s .  c  om
    while (!toSort.isEmpty()) {

        next = toSort.pollFirst();
        handleMenu(next, parents.get(next));
        if (ListHelper.hasElements(next.getItems())) {
            sortInMemory(next.getItems());
            toSort.addAll(next.getItems());
            for (Menu m : next.getItems()) {
                parents.put(m, next);
            }
        }
    }
}

From source file:eu.ggnet.dwoss.report.entity.Report.java

/**
 * Returns all Lines of the Report for Category Invoiced.
 * This consists of:/* w w w. j a va2s  .  c o 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>
 * @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 NavigableSet<ReportLine> filterInvoiced() {
    NavigableSet<ReportLine> result = new TreeSet<>();
    for (ReportLine line : lines) {
        if (line.getDocumentType() == DocumentType.CAPITAL_ASSET)
            result.add(line); // There is no way a capital Asset can be returned.
        // Only if we are fully repayed in this report, we are not in the invoiced result.
        if (line.getDocumentType() == DocumentType.INVOICE && !line.isFullRepayedIn(lines))
            result.add(line);
        if (line.isPartialRepayment() && !line.isFullRepayedIn(lines)
                && lines.contains(line.getSingleReference(DocumentType.INVOICE)))
            result.add(line);
    }
    return result;
}

From source file:eu.ggnet.dwoss.report.entity.Report.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:// www .  j a v  a2  s  . co 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>
 * @return all Lines of the Report which represent Positions of CreditMemos and Annulation Invoices but the associated Invoices have been reported before.
 */
public NavigableSet<ReportLine> filterRepayed() {
    NavigableSet<ReportLine> result = new TreeSet<>();
    for (ReportLine line : lines) {
        if (line.isFullRepayment() && !lines.contains(line.getSingleReference(DocumentType.INVOICE)))
            result.add(line);
        // Implies ( !lines.contaions(null) ) == true
        if (line.isPartialRepayment() && !line.isFullRepayedIn(lines)
                && !lines.contains(line.getSingleReference(DocumentType.INVOICE)))
            result.add(line);
    }
    return result;
}

From source file:eu.ggnet.dwoss.report.entity.Report.java

/**
 * Returns all Lines of the Report for Category Invoiced, split by mfgDate - startOfReport &lt; 1 year and the rest.
 * This consists of:/*  w  w  w .jav  a2 s .c o  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>
 * @return all Lines of the Report for Category Invoiced.
 */
public YearSplit filterInvoicedSplit() {
    NavigableSet<ReportLine> pastSplit = filterInvoiced();
    NavigableSet<ReportLine> preSplit = new TreeSet<>();
    Date splitter = DateUtils.addYears(startingDate, -1);
    for (ReportLine line : pastSplit) {
        if (splitter.before(line.getMfgDate()))
            preSplit.add(line);
    }
    pastSplit.removeAll(preSplit);
    return new YearSplit(startingDate, preSplit, pastSplit);
}

From source file:com.ejisto.modules.dao.local.LocalMockedFieldsDao.java

private MockedField saveField(MockedField field, boolean update) {
    MockedField newField = cloneField(field);
    NavigableSet<MockedFieldContainer> container;
    Optional<NavigableSet<MockedFieldContainer>> result = getDatabase().getMockedFields(field.getContextPath());
    if (!result.isPresent()) {
        getDatabase().registerContextPath(field.getContextPath());
        container = getDatabase().getMockedFields(field.getContextPath())
                .orElseThrow(IllegalStateException::new);
    } else {//ww  w.ja  va 2 s. c  om
        container = result.get();
    }
    if (update) {
        container.removeIf(c -> c.wraps(newField));
    }
    container.add(MockedFieldContainer.from(field));
    return newField;
}

From source file:ch.algotrader.service.CalendarServiceImpl.java

/**
 * Get all open times for this date/*from  w ww .j a  v a2s .  c  om*/
 */
private NavigableSet<Date> getOpenTimes(final Exchange exchange, final Date date) {

    Validate.notNull(exchange, "exchange not found");
    Validate.notNull(date, "date is null");

    Validate.isTrue(exchange.getTradingHours().size() > 0, "no trading hours defined for exchange " + exchange);

    NavigableSet<Date> openTimes = new TreeSet<>();
    for (TradingHours tradingHours : exchange.getTradingHours()) {
        TimeInterval timeInterval = getTimeInterval(date, tradingHours);
        if (timeInterval != null) {
            openTimes.add(timeInterval.getFrom());
        }
    }
    return openTimes;
}

From source file:ch.algotrader.service.CalendarServiceImpl.java

/**
 * Get all close times for this date//ww  w.jav  a 2s .c  o m
 */
private NavigableSet<Date> getCloseTimes(final Exchange exchange, final Date date) {

    Validate.notNull(exchange, "exchange not found");
    Validate.notNull(date, "date is null");

    Validate.isTrue(exchange.getTradingHours().size() > 0, "no trading hours defined for exchange " + exchange);

    NavigableSet<Date> openTimes = new TreeSet<>();
    for (TradingHours tradingHours : exchange.getTradingHours()) {
        TimeInterval timeInterval = getTimeInterval(date, tradingHours);
        if (timeInterval != null) {
            openTimes.add(timeInterval.getTo());
        }
    }
    return openTimes;
}

From source file:eu.ggnet.dwoss.report.entity.ReportLine.java

/**
 * Returns a Set of document types, which are references exist.
 * <p>//w  w  w  .  ja  v a 2s  .c o m
 * @return a Set of document types, which are references exist.
 */
public NavigableSet<DocumentType> getReferenceTypes() {
    NavigableSet<DocumentType> types = new TreeSet<>();
    for (ReportLine ref : refrences) {
        types.add(ref.getDocumentType());
    }
    return types;
}

From source file:com.google.gwt.emultest.java.util.TreeSetTest.java

public void testCeiling() {
    NavigableSet<E> set = createNavigableSet();

    set.add(getKeys()[0]);
    assertEquals(getKeys()[0], set.ceiling(getKeys()[0]));
    assertEquals(getKeys()[0], set.ceiling(getLessThanMinimumKey()));
    assertEquals(set.toArray()[0], set.ceiling(getLessThanMinimumKey()));

    set.add(getKeys()[1]);/*from  w  w  w .j a v a  2 s  .  c om*/
    assertEquals(getKeys()[0], set.ceiling(getLessThanMinimumKey()));
    assertEquals(getKeys()[0], set.ceiling(getKeys()[0]));
    assertEquals(getKeys()[1], set.ceiling(getKeys()[1]));
    assertEquals(null, set.ceiling(getGreaterThanMaximumKey()));
}

From source file:com.google.gwt.emultest.java.util.TreeSetTest.java

public void testHigher() {
    NavigableSet<E> set = createNavigableSet();

    set.add(getKeys()[0]);
    assertEquals(null, set.higher(getKeys()[0]));
    assertEquals(getKeys()[0], set.higher(getLessThanMinimumKey()));
    assertEquals(set.toArray()[0], set.higher(getLessThanMinimumKey()));

    set.add(getKeys()[1]);//  w w w  .  j  a v a2  s.c o m
    assertEquals(getKeys()[0], set.higher(getLessThanMinimumKey()));
    assertEquals(getKeys()[1], set.higher(getKeys()[0]));
    assertEquals(null, set.higher(getKeys()[1]));
    assertEquals(null, set.higher(getGreaterThanMaximumKey()));
}