Example usage for java.util Collections emptyList

List of usage examples for java.util Collections emptyList

Introduction

In this page you can find the example usage for java.util Collections emptyList.

Prototype

@SuppressWarnings("unchecked")
public static final <T> List<T> emptyList() 

Source Link

Document

Returns an empty list (immutable).

Usage

From source file:ch.eitchnet.csvrestendpoint.components.CsvDataHandler.java

public List<String> getCsvNames() {

    File csvDataDir = getCsvDataDir();
    if (!csvDataDir.isDirectory()) {
        logger.error("CSV Data Dir is not a directory at " + csvDataDir.getAbsolutePath());
        return Collections.emptyList();
    }//from ww  w .ja va2  s. c o  m

    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(csvDataDir.toPath())) {

        List<String> names = new ArrayList<>();

        for (Iterator<Path> iter = directoryStream.iterator(); iter.hasNext();) {
            Path path = iter.next();
            String name = path.toFile().getName();
            if (name.endsWith(".csv"))
                names.add(name.substring(0, name.length() - 4));
        }

        return names;

    } catch (Exception e) {
        throw new RuntimeException("Failed to read CSV names due to " + e.getMessage());
    }
}

From source file:ch.ralscha.extdirectspring.bean.ExtDirectStoreReadRequest.java

public ExtDirectStoreReadRequest() {
    this.filters = Collections.emptyList();
    this.sorters = Collections.emptyList();
    this.groups = Collections.emptyList();
    this.params = Collections.emptyMap();
}

From source file:com.googlecode.wicketelements.security.AnnotationSecurityCheck.java

public <T extends IRequestableComponent> List<Class<? extends SecurityConstraint>> findSecurityConstraintsForEnable(
        final T componentParam) {
    Reqs.PARAM_REQ.Object.requireNotNull(componentParam,
            "Cannot find security constraints an a null component!");
    List<Class<? extends SecurityConstraint>> list = Collections.emptyList();
    if (componentParam.getClass().isAnnotationPresent(EnableAction.class)) {
        final EnableAction annot = componentParam.getClass().getAnnotation(EnableAction.class);
        list = Arrays.asList(annot.constraints());
    }//from w w  w  .  j ava  2 s . c  o m
    return list;
}

From source file:net.sourceforge.subsonic.controller.StatusChartController.java

public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String type = request.getParameter("type");
    int index = Integer.parseInt(request.getParameter("index"));

    List<TransferStatus> statuses = Collections.emptyList();
    if ("stream".equals(type)) {
        statuses = statusService.getAllStreamStatuses();
    } else if ("download".equals(type)) {
        statuses = statusService.getAllDownloadStatuses();
    } else if ("upload".equals(type)) {
        statuses = statusService.getAllUploadStatuses();
    }//w ww.  ja  v  a  2s . c o m

    if (index < 0 || index >= statuses.size()) {
        return null;
    }
    TransferStatus status = statuses.get(index);

    TimeSeries series = new TimeSeries("Kbps", Millisecond.class);
    TransferStatus.SampleHistory history = status.getHistory();
    long to = System.currentTimeMillis();
    long from = to - status.getHistoryLengthMillis();
    Range range = new DateRange(from, to);

    if (!history.isEmpty()) {

        TransferStatus.Sample previous = history.get(0);

        for (int i = 1; i < history.size(); i++) {
            TransferStatus.Sample sample = history.get(i);

            long elapsedTimeMilis = sample.getTimestamp() - previous.getTimestamp();
            long bytesStreamed = Math.max(0L, sample.getBytesTransfered() - previous.getBytesTransfered());

            double kbps = (8.0 * bytesStreamed / 1024.0) / (elapsedTimeMilis / 1000.0);
            series.addOrUpdate(new Millisecond(new Date(sample.getTimestamp())), kbps);

            previous = sample;
        }
    }

    // Compute moving average.
    series = MovingAverage.createMovingAverage(series, "Kbps", 20000, 5000);

    // Find min and max values.
    double min = 100;
    double max = 250;
    for (Object obj : series.getItems()) {
        TimeSeriesDataItem item = (TimeSeriesDataItem) obj;
        double value = item.getValue().doubleValue();
        if (item.getPeriod().getFirstMillisecond() > from) {
            min = Math.min(min, value);
            max = Math.max(max, value);
        }
    }

    // Add 10% to max value.
    max *= 1.1D;

    // Subtract 10% from min value.
    min *= 0.9D;

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_HEIGHT, Color.white);
    plot.setBackgroundPaint(background);

    XYItemRenderer renderer = plot.getRendererForDataset(dataset);
    renderer.setSeriesPaint(0, Color.blue.darker());
    renderer.setSeriesStroke(0, new BasicStroke(2f));

    // Set theme-specific colors.
    Color bgColor = getBackground(request);
    Color fgColor = getForeground(request);

    chart.setBackgroundPaint(bgColor);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setRange(range);
    domainAxis.setTickLabelPaint(fgColor);
    domainAxis.setTickMarkPaint(fgColor);
    domainAxis.setAxisLinePaint(fgColor);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setRange(new Range(min, max));
    rangeAxis.setTickLabelPaint(fgColor);
    rangeAxis.setTickMarkPaint(fgColor);
    rangeAxis.setAxisLinePaint(fgColor);

    ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, IMAGE_WIDTH, IMAGE_HEIGHT);

    return null;
}

From source file:dlauncher.modpacks.download.ModPackListingVanilla.java

@Override
public Collection<? extends UnresolvedModPack> readModPacksFromResource(byte[] resourceBytes)
        throws IOException {
    JSONObject json = new JSONObject(new String(resourceBytes, Charset.forName("UTF-8")));
    final DefaultModPack modpack = new DefaultModPack("Vanilla", Arrays.asList("Mojang AB"), null,
            "This is the vanilla minecraft", null,
            new DefaultDownloadLocation(this.getClass().getResource("/images/TEMP_Vanilla.png")),
            new URL("https://minecraft.net/"));
    UnresolvedModPack unresolved = new UnresolvedModPack() {

        @Override/*w w  w .  ja v a2s  . com*/
        public Collection<? extends ModPackVersionDescription> getRequiredDependencies() {
            return Collections.emptyList();
        }

        @Override
        public ModPack createModPack(Map<String, ModPack> dependencies) {
            return modpack;
        }

        @Override
        public String getName() {
            return modpack.getName();
        }
    };
    JSONArray versions = json.getJSONArray("versions");
    for (int i = 0; i < versions.length(); i++)
        modpack.addModPackVersion(new VanillaModPackVersion(versions.getJSONObject(i), modpack));
    return Collections.singletonList(unresolved);
}

From source file:Main.java

/**
 * Functions as per {@link Collections#unmodifiableList(List)} with the exception that if the
 * given list is null, this method will return an unmodifiable empty list as per
 * {@link Collections#emptyList()}.//from   w  w  w.ja  v  a2 s .  co m
 * 
 * @param list the list for which an unmodifiable view is to be returned
 * @return an unmodifiable view of the specified list, or an unmodifiable empty list if the
 *         given list is null
 */
public static <T> List<T> unmodifiableListNullSafe(List<? extends T> list) {
    if (list == null) {
        return Collections.emptyList();
    }
    return Collections.unmodifiableList(list);
}

From source file:org.n52.series.db.beans.ServiceInfo.java

public ServiceInfo() {
    noDataValues = Collections.emptyList();
}

From source file:com.gistlabs.mechanize.document.json.node.impl.AbstractJsonNode.java

@Override
public List<? extends JsonNode> getChildren() {
    return Collections.emptyList();
}

From source file:edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalUrisForVCards.java

@Override
public List<String> findAdditionalURIsToIndex(Statement stmt) {
    if (stmt == null) {
        return Collections.emptyList();
    }//w w w . j  a  va  2  s.com

    RDFNode sNode = stmt.getSubject();
    if (sNode == null) {
        log.warn("subject of modified statement was null.");
        return Collections.emptyList();
    }

    if (!sNode.isURIResource()) {
        return Collections.emptyList();
    }

    Resource subject = sNode.asResource();
    String uri = subject.getURI();
    if (uri == null) {
        log.warn("subject of modified statement had a null URI.");
        return Collections.emptyList();
    }

    return ownersOfVCard(uri);
}

From source file:org.openlmis.fulfillment.web.shipmentdraft.ShipmentDraftDtoBuilder.java

/**
 * Create a new list of {@link ShipmentDraftDto} based on data
 * from {@link ShipmentDraft}./*from  www . j  a  v  a2 s .co m*/
 *
 * @param shipments collection used to create {@link ShipmentDraftDto} list (can be {@code null})
 * @return new list of {@link ShipmentDraftDto}. Empty list if passed argument is {@code null}.
 */
public List<ShipmentDraftDto> build(Collection<ShipmentDraft> shipments) {
    if (null == shipments) {
        return Collections.emptyList();
    }
    return shipments.stream().map(this::export).collect(Collectors.toList());
}