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:io.gravitee.repository.redis.management.RedisGroupRepository.java

@Override
public Group create(Group item) throws TechnicalException {
    if (item != null && item.getAdministrators() == null) {
        item.setAdministrators(Collections.emptyList());
    }/*from w  ww  .j  ava 2  s  . c o  m*/
    return convert(internalRepository.saveOrUpdate(convert(item)));
}

From source file:com.netflix.hystrix.contrib.javanica.utils.TypeHelper.java

/**
 * Unwinds parametrized type into plain list that contains all parameters for the given type including nested parameterized types,
 * for example calling the method for the following type
 * <code>//from w w w .  ja va2s  .c om
 * GType<GType<GDoubleType<GType<GDoubleType<Parent, Parent>>, Parent>>>
 * </code>
 * will return list of 8 elements:
 * <code>
 * [GType, GType, GDoubleType, GType, GDoubleType, Parent, Parent, Parent]
 * </code>
 * if the given type is not parametrized then returns list with one element which is given type passed into method.
 *
 * @param type the parameterized type
 * @return list of {@link Type}
 */
@ParametersAreNonnullByDefault
public static List<Type> getAllParameterizedTypes(Type type) {
    Validate.notNull(type, "type cannot be null");
    List<Type> types = new ArrayList<Type>();
    TreeTraverser<Type> typeTraverser = new TreeTraverser<Type>() {
        @Override
        public Iterable<Type> children(Type root) {
            if (root instanceof ParameterizedType) {
                ParameterizedType pType = (ParameterizedType) root;
                return Arrays.asList(pType.getActualTypeArguments());

            }
            return Collections.emptyList();
        }
    };
    for (Type t : typeTraverser.breadthFirstTraversal(type)) {
        types.add(t);
    }
    return types;
}

From source file:io.github.autsia.crowly.controllers.rest.MentionsController.java

@RequestMapping(value = "/getByCampaign", method = RequestMethod.GET)
public List<Mention> getCampaignsForCurrentUser(@RequestParam String campaignId, HttpServletResponse response) {
    try {/*  ww  w  .j a  va  2 s.  c o m*/
        return mentionRepository.findByCampaignId(campaignId);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return Collections.emptyList();
    }
}

From source file:com.puppetlabs.geppetto.forge.v1.service.ModuleService.java

/**
 * @param keyword/*from  w w  w. jav a  2s.  c om*/
 *            KeyWord to use in the search. May be <code>null</code> to get all modules.
 * @return All Modules that matches the given keyword
 * @throws IOException
 */
public List<ModuleInfo> search(String keyword) throws IOException {
    List<ModuleInfo> modules = null;
    try {
        modules = forgeClient.getV1(Constants.COMMAND_GROUP_MODULES,
                keyword == null ? null : Collections.singletonMap("q", keyword), Constants.LIST_MODULE_INFO);
    } catch (HttpResponseException e) {
        if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND)
            throw e;
    }
    if (modules == null)
        modules = Collections.emptyList();
    return modules;
}

From source file:com.puppetlabs.geppetto.forge.v1.impl.DefaultModuleService.java

@Override
public List<ModuleInfo> search(String keyword) throws IOException {
    List<ModuleInfo> modules = null;
    try {/*from ww w .j a v a2 s .  c o  m*/
        modules = forgeClient.getV1(Constants.COMMAND_GROUP_MODULES,
                keyword == null ? null : Collections.singletonMap("q", keyword), LIST_MODULE_INFO);
    } catch (HttpResponseException e) {
        if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND)
            throw e;
    }
    if (modules == null)
        modules = Collections.emptyList();
    return modules;
}

From source file:org.restlet.ext.httpclient.internal.IgnoreCookieSpec.java

/**
 * Returns an empty list.//  w w  w.j  a  v  a 2  s.c  om
 * 
 * @return An empty list.
 */
public List<Header> formatCookies(List<Cookie> cookies) {
    return Collections.emptyList();
}

From source file:cc.altruix.econsimtr01.App.java

public void run(final InputStream stream) {
    try {// w  ww.  j a va 2 s.com
        final String dirName = String.format("%s/econsim-tr01-%d", System.getProperty("user.dir"),
                new Date().getTime());
        final File dir = new File(dirName);
        //noinspection ResultOfMethodCallIgnored
        dir.mkdir();

        final String theoryTxt = IOUtils.toString(stream);
        final SimParametersProvider simParametersProvider = new SimParametersProvider(theoryTxt,
                Collections.emptyList(), Collections.emptyList(), Collections.emptyList(),
                Collections.emptyList());
        final List<ResourceFlow> flows = new LinkedList<>();
        final StringBuilder log = new StringBuilder();

        new Simulation1(log, flows, simParametersProvider).run();

        final File simResults = new File(String.format("%s/simResults.pl", dir.getAbsolutePath()));
        FileUtils.writeStringToFile(simResults, log.toString());
        createCsvFile(dir, simResults);
        createFlowsDiagram(dir, flows);
        createParamsFile(dir, theoryTxt);
    } catch (final IOException exception) {
        exception.printStackTrace();
    }
}

From source file:com.netflix.spinnaker.igor.artifacts.ArtifactExtractor.java

public List<Artifact> extractArtifacts(GenericBuild build) {
    final String messageString;
    try {//w w  w . j  a  va  2 s  .  c o  m
        messageString = objectMapper.writeValueAsString(build);
    } catch (JsonProcessingException e) {
        log.error("Error processing JSON: {}", e);
        return Collections.emptyList();
    }

    return getArtifactTemplates(build).stream()
            .flatMap(template -> processTemplate(template, messageString).stream())
            .collect(Collectors.toList());
}

From source file:com.thoughtworks.go.plugin.access.authorization.v2.AuthenticationResponseDTO.java

public AuthenticationResponse toDomainModel() {
    return new AuthenticationResponse(this.user != null ? this.user.toDomainModel() : null,
            ListUtils.defaultIfNull(this.roles, Collections.emptyList()));
}

From source file:org.madsonic.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 .  j a v a2 s .  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.gray.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;
}