Example usage for java.util SortedSet first

List of usage examples for java.util SortedSet first

Introduction

In this page you can find the example usage for java.util SortedSet first.

Prototype

E first();

Source Link

Document

Returns the first (lowest) element currently in this set.

Usage

From source file:com.espertech.esper.filter.TestFilterSpecParamComparator.java

public void testCompareAll() {
    SortedSet<FilterOperator> sorted = new TreeSet<FilterOperator>(comparator);

    for (int i = 0; i < FilterOperator.values().length; i++) {
        FilterOperator op = FilterOperator.values()[i];
        sorted.add(op);//w ww .j  av  a 2  s.c om
    }

    assertEquals(FilterOperator.EQUAL, sorted.first());
    assertEquals(FilterOperator.BOOLEAN_EXPRESSION, sorted.last());
    assertEquals(
            "[EQUAL, IS, IN_LIST_OF_VALUES, RANGE_OPEN, RANGE_HALF_OPEN, RANGE_HALF_CLOSED, RANGE_CLOSED, LESS, LESS_OR_EQUAL, GREATER_OR_EQUAL, GREATER, NOT_RANGE_CLOSED, NOT_RANGE_HALF_CLOSED, NOT_RANGE_HALF_OPEN, NOT_RANGE_OPEN, NOT_IN_LIST_OF_VALUES, NOT_EQUAL, IS_NOT, BOOLEAN_EXPRESSION]",
            sorted.toString());

    log.debug(".testCompareAll " + Arrays.toString(sorted.toArray()));
}

From source file:org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSelectionStrategy.java

/**
 * Select the disposition schedule to use given there is more than one
 *
 * @param recordFolders//from   w  w w .j ava 2s. c om
 * @return
 */
public NodeRef selectDispositionScheduleFrom(List<NodeRef> recordFolders) {
    if (recordFolders == null || recordFolders.isEmpty()) {
        return null;
    } else {
        //      46 CHAPTER 2
        //      Records assigned more than 1 disposition must be retained and linked to the record folder (category) with the longest
        //      retention period.

        // Assumption: an event-based disposition action has a longer retention
        // period than a time-based one - as we cannot know when an event will occur
        // TODO Automatic events?

        NodeRef recordFolder = null;
        if (recordFolders.size() == 1) {
            recordFolder = recordFolders.get(0);
        } else {
            SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
            sortedFolders.addAll(recordFolders);
            recordFolder = sortedFolders.first();
        }

        DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(recordFolder);

        if (logger.isDebugEnabled()) {
            logger.debug("Selected disposition schedule: " + dispSchedule);
        }

        NodeRef result = null;
        if (dispSchedule != null) {
            result = dispSchedule.getNodeRef();
        }
        return result;
    }
}

From source file:org.apache.hadoop.hbase.regionserver.Segment.java

/**
 * Returns the first cell in the segment that has equal or greater key than the given cell
 * @return the first cell in the segment that has equal or greater key than the given cell
 *//*w ww. j  a  v a2 s  .  c  om*/
public Cell getFirstAfter(Cell cell) {
    SortedSet<Cell> snTailSet = tailSet(cell);
    if (!snTailSet.isEmpty()) {
        return snTailSet.first();
    }
    return null;
}

From source file:pl.edu.agh.samm.metrics.SuggestedMetricsComputationEngineImpl.java

private void addCorrelation(IMetric metricOne, IMetric metricTwo, double correlation) {
    if (!metricsWithCorrelation.containsKey(metricOne)) {
        metricsWithCorrelation.put(metricOne, new TreeSet<MetricWithCorrelation>());
    }/*from w  w  w.  j a  va  2  s.  c  o  m*/
    SortedSet<MetricWithCorrelation> set = metricsWithCorrelation.get(metricOne);
    set.add(new MetricWithCorrelation(metricOne, metricTwo, correlation));
    if (set.size() > SUGGESTED_METRICS_COUNT) {
        set.remove(set.first());
    }
}

From source file:org.stockwatcher.web.StockController.java

@RequestMapping(value = "/{symbol}", method = RequestMethod.GET)
public String displayStockDetail(@PathVariable String symbol, Model model, HttpServletRequest request) {
    model.addAttribute("stock", dao.getStockBySymbol(symbol));
    Date tradeDate = applicationProps.getLastTradeDate();
    SortedSet<Trade> trades = dao.getTradesBySymbolAndDate(symbol, tradeDate);
    model.addAttribute("trades", getUniqueTrades(trades));
    long elapsedTime = trades.size() == 0 ? 0
            : getElapsedTime(trades.first().getTimestamp(), trades.last().getTimestamp());
    User user = (User) request.getSession().getAttribute("user");
    model.addAttribute("watchLists",
            user == null ? Collections.EMPTY_SET : watchListDao.getWatchListsByUserId(user.getId()));
    model.addAttribute("lastClosePrice", dao.getLastClosePriceForSymbol(symbol));
    model.addAttribute("elapsedTime", elapsedTime);
    model.addAttribute("liveTrading", applicationProps.isTradingLive());
    model.addAttribute("watchCount", watchListDao.getWatchCount(symbol));
    dao.incrementStockViewCount(symbol);
    return "stock";
}

From source file:ru.org.linux.tag.TagController.java

/**
 *     .//from  w w w  .  ja v a 2s. c  om
 *
 * @param firstLetter : ?  ? ,    
 * @return  web-
 */
@RequestMapping("/tags/{firstLetter}")
public ModelAndView showTagListHandler(@PathVariable String firstLetter) throws TagNotFoundException {
    ModelAndView modelAndView = new ModelAndView("tags");

    SortedSet<String> firstLetters = tagService.getFirstLetters();
    modelAndView.addObject("firstLetters", firstLetters);

    if (Strings.isNullOrEmpty(firstLetter)) {
        firstLetter = firstLetters.first();
    }

    modelAndView.addObject("currentLetter", firstLetter);

    Map<String, Integer> tags = tagService.getTagsByFirstLetter(firstLetter);

    if (tags.isEmpty()) {
        throw new TagNotFoundException("Tag list is empty");
    }
    modelAndView.addObject("tags", tags);

    return modelAndView;
}

From source file:org.eclipse.skalli.commons.StatisticsTest.java

private void assertMixedStatistics(Statistics stats) {
    SortedSet<UsageInfo> usageInfo = stats.getUsageInfo();
    assertEquals(3, usageInfo.size());// w  w w. j av a  2 s. c  o  m
    SortedSet<UserInfo> userInfo = stats.getUserInfo();
    assertEquals(2, userInfo.size());
    assertEquals(0, userInfo.first().getSequenceNumber());
    assertEquals(5, userInfo.last().getSequenceNumber());
    SortedSet<BrowserInfo> browserInfo = stats.getBrowserInfo();
    assertEquals(1, browserInfo.size());
    assertEquals(6, browserInfo.first().getSequenceNumber());
    SortedSet<SearchInfo> searchInfo = stats.getSearchInfo();
    assertEquals(2, searchInfo.size());
    assertEquals(2, searchInfo.first().getSequenceNumber());
    assertEquals(8, searchInfo.last().getSequenceNumber());
    SortedSet<RefererInfo> referInfo = stats.getRefererInfo();
    assertEquals(1, referInfo.size());
    assertEquals(3, referInfo.first().getSequenceNumber());
    SortedSet<ResponseTimeInfo> responseInfo = stats.getResponseTimeInfo();
    assertEquals(1, responseInfo.size());
    assertEquals(7, responseInfo.first().getSequenceNumber());

    assertEquals(userInfo.first().getTimestamp(), stats.getStartDate());
    assertEquals(usageInfo.last().getTimestamp(), stats.getEndDate());
    assertEquals(usageInfo.last().getSequenceNumber() + 1, stats.getSequenceNumber());
}

From source file:ca.travelagency.invoice.destinations.DestinationFormPanel.java

private void initialize(DestinationsPanel destinationsPanel, InvoiceDestination invoiceDestination) {
    if (DaoEntityModelFactory.isPersisted(invoiceDestination)) {
        return;// w  w  w .j  a v  a2 s  .com
    }
    SortedSet<InvoiceDestination> destinations = destinationsPanel.getDaoEntity().getInvoiceDestinations();
    switch (destinations.size()) {
    case 0:
        invoiceDestination.setDeparturePlace(parameterRepository.getDefaultDeparturePlace());
        break;
    case 1:
        InvoiceDestination first = destinations.first();
        invoiceDestination.setDeparturePlace(first.getArrivalPlace());
        invoiceDestination.setDepartureDate(DateUtils.addDays(first.getDepartureDate(), TRAVEL_DAY_RANGE));
        invoiceDestination.setArrivalPlace(first.getDeparturePlace());
        break;
    }
}

From source file:org.kalypso.model.wspm.ui.view.chart.layer.wsp.WspLayer.java

@Override
public IDataRange<Double> getTargetRange(final IDataRange<Double> domainIntervall) {
    final WaterlevelRenderData[] renderData = getRenderData();
    if (renderData.length == 0)
        return null;

    final SortedSet<Double> values = new TreeSet<>();

    for (final WaterlevelRenderData data : renderData) {
        final double value = data.getValue();
        values.add(value);/*  w  ww.  j a  v  a 2s.  c om*/
    }

    final Double min = values.first();
    final Double max = values.last();
    return new DataRange<>(min, max);
}

From source file:io.wcm.handler.media.format.impl.MediaFormatHandlerImpl.java

/**
 * Detect matching media format.//from w  w  w .  j  a va2 s  .c  o m
 * @param extension File extension
 * @param fileSize File size
 * @param width Image width (or 0 if not image)
 * @param height Image height (or 0 if not image)
 * @return Media format or null if no matching media format found
 */
@Override
public MediaFormat detectMediaFormat(String extension, long fileSize, long width, long height) {
    SortedSet<MediaFormat> matchingFormats = detectMediaFormats(extension, fileSize, width, height);
    return !matchingFormats.isEmpty() ? matchingFormats.first() : null;
}