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:com.netflix.spinnaker.igor.scm.AbstractCommitController.java

@RequestMapping(value = "/{projectKey}/{repositorySlug}/compareCommits")
public List<Map<String, Object>> compareCommits(@PathVariable String projectKey,
        @PathVariable String repositorySlug, @RequestParam Map<String, String> requestParams) {
    if (!requestParams.containsKey("to") || !requestParams.containsKey("from")) {
        throw new MissingParametersException();
    }/*from  ww  w.j a  va2s  . co  m*/

    return Collections.emptyList();
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.controllers.util.GlobalMessages.java

public static void addFlashMessage(final RedirectAttributes model, final String messageHolder,
        final String messageKey, final Object[] attributes) {
    final GlobalMessage message = new GlobalMessage();
    message.setCode(messageKey);//  w w  w .  java 2 s.c o  m
    message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList());

    final Map<String, ?> flashModelMap = model.getFlashAttributes();
    if (flashModelMap.containsKey(messageHolder)) {
        final List<GlobalMessage> messages = new ArrayList<>(
                (List<GlobalMessage>) flashModelMap.get(messageHolder));
        messages.add(message);
        model.addFlashAttribute(messageHolder, messages);
    } else {
        model.addFlashAttribute(messageHolder, Collections.singletonList(message));
    }
}

From source file:de.mg.stock.server.update.StockUpdateFromGoogleHistorical.java

@Override
public List<DayPrice> get(String symbol) {

    String shortSymbol = symbol.substring(0, symbol.lastIndexOf('.'));

    LocalDateTime fetchTime = dateTimeProvider.now();

    String response = httpUtil.get(
            "http://www.google.com/finance/historical?output=csv&startdate=Jan+1%2C+2000&q=" + shortSymbol);
    if (isEmpty(response)) {
        logger.warning("nothing received for " + shortSymbol);
        return Collections.emptyList();
    }/*from  ww  w.j a  va 2  s. c  om*/

    String[] lines = response.split(System.getProperty("line.separator"));
    if (lines.length < 2) {
        logger.warning("no lines received for " + shortSymbol);
        return Collections.emptyList();
    }
    if (!lines[0].contains("Date,Open,High,Low,Close,Volume")) {
        logger.warning("wrong header for " + shortSymbol + ": " + lines[0]);
        return Collections.emptyList();
    }

    List<DayPrice> result = new ArrayList<>();

    for (int i = 1; i < lines.length; i++) {
        StringTokenizer tok = new StringTokenizer(lines[i], ",");
        LocalDate date = toLocalDate(tok.nextToken(), "dd-MMMM-yy", Locale.ENGLISH);
        DayPrice dayPrice = new DayPrice(date);
        dayPrice.setFetchedAt(fetchTime);

        // skip
        tok.nextToken();

        dayPrice.setMax(toLong(tok.nextToken()));
        dayPrice.setMin(toLong(tok.nextToken()));

        Long close = toLong(tok.nextToken());
        if (dayPrice.getMax() == null)
            dayPrice.setMax(close);
        if (dayPrice.getMin() == null)
            dayPrice.setMin(close);

        if (dayPrice.getMax() != null && dayPrice.getMin() != null && dayPrice.getMax() != 0
                && dayPrice.getMin() != 0)
            result.add(dayPrice);
    }

    return result;
}

From source file:com.haulmont.timesheets.SystemDataManager.java

public <T extends Entity> List<T> getEntitiesByCodes(Class<T> clazz, List<String> codes,
        @Nullable String viewName) {
    if (codes.isEmpty()) {
        return Collections.emptyList();
    }/*www .j  a v  a  2  s. co m*/
    LoadContext<T> loadContext = new LoadContext<>(clazz);
    MetaClass metaClass = metadata.getSession().getClassNN(clazz);
    loadContext.setQueryString("select e from " + metaClass.getName() + " e where e.code in :codes")
            .setParameter("codes", codes);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    return dataManager.loadList(loadContext);
}

From source file:net.metanotion.web.html.SafeString.java

@Override
public Iterator<Object> children() {
    return Collections.emptyList().iterator();
}

From source file:org.graylog.plugins.pipelineprocessor.rest.PipelineSource.java

@JsonCreator
public static PipelineSource create(@JsonProperty("id") @Id @ObjectId @Nullable String id,
        @JsonProperty("title") String title, @JsonProperty("description") @Nullable String description,
        @JsonProperty("source") String source, @Nullable @JsonProperty("created_at") DateTime createdAt,
        @Nullable @JsonProperty("modified_at") DateTime modifiedAt) {
    return builder().id(id).title(title).description(description).source(source).createdAt(createdAt)
            .modifiedAt(modifiedAt).stages(Collections.emptyList()).build();
}

From source file:com.exxonmobile.ace.hybris.storefront.controllers.util.GlobalMessages.java

public static void addFlashMessage(final RedirectAttributes model, final String messageHolder,
        final String messageKey, final Object[] attributes) {
    final GlobalMessage message = new GlobalMessage();
    message.setCode(messageKey);//from w w  w  .  j av a2 s.c  om
    message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList());

    final Map<String, ?> flashModelMap = model.getFlashAttributes();
    if (flashModelMap.containsKey(messageHolder)) {
        final List<GlobalMessage> messages = new ArrayList<GlobalMessage>(
                (List<GlobalMessage>) flashModelMap.get(messageHolder));
        messages.add(message);
        model.addFlashAttribute(messageHolder, messages);
    } else {
        model.addFlashAttribute(messageHolder, Collections.singletonList(message));
    }
}

From source file:io.wcm.caravan.pipeline.extensions.hal.crawler.OutputProcessorsTest.java

@Test
public void report_shouldListAllCrawledUrlsInFlatLinkList() {

    OutputProcessor processor = OutputProcessors.report();

    HalResource resource = new HalResource("/resource").addLinks("section", new Link("/resource-1"),
            new Link("/resource-2"));
    HalResource resource1 = new HalResource("/resource-1").addLinks("item", new Link("/resource-1-1"));
    HalResource resource1_1 = new HalResource("/resource-1-1");
    HalResource resource2 = new HalResource("/resource-2");

    JsonPipelineOutput result2 = processor.process(createJsonPipelineOutput("section", resource2),
            Collections.emptyList());
    JsonPipelineOutput result1_1 = processor.process(createJsonPipelineOutput("item", resource1_1),
            Collections.emptyList());
    JsonPipelineOutput result1 = processor.process(createJsonPipelineOutput("section", resource1),
            ImmutableList.of(result1_1));
    JsonPipelineOutput output = processor.process(createJsonPipelineOutput(null, resource),
            ImmutableList.of(result1, result2));
    HalResource hal = new HalResource(output.getPayload());

    assertEquals("/resource", hal.getLink().getHref());
    assertEquals(2, hal.getLinks("section").size());
    assertEquals("/resource-1", hal.getLinks("section").get(0).getHref());
    assertEquals(1, hal.getLinks("item").size());
    assertEquals("/resource-1-1", hal.getLinks("item").get(0).getHref());

}

From source file:org.alfresco.util.exec.RuntimeExecShutdownBean.java

/**
 * Initializes the bean with empty defaults, i.e. it will do nothing
 *///from  w w w. ja v  a 2  s.  c  om
public RuntimeExecShutdownBean() {
    this.shutdownCommands = Collections.emptyList();
    this.executed = false;
}

From source file:cec.easyshop.core.suggestion.impl.DefaultSimpleSuggestionServiceTest.java

@Test
public void testGetReferencedProductsForBoughtCategory() {
    final UserModel user = mock(UserModel.class);
    final CategoryModel category = mock(CategoryModel.class);

    final Integer limit = NumberUtils.INTEGER_ONE;
    final boolean excludePurchased = true;
    final List<ProductModel> result = Collections.emptyList();
    final ProductReferenceTypeEnum type = ProductReferenceTypeEnum.FOLLOWUP;
    given(simpleSuggestionDao.findProductsRelatedToPurchasedProductsByCategory(category, user, type,
            excludePurchased, limit)).willReturn(result);

    final List<ProductModel> actual = defaultSimpleSuggestionService
            .getReferencesForPurchasedInCategory(category, user, type, excludePurchased, limit);
    Assert.assertEquals(result, actual);
}