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.civis.utils.html.parser.HtmlParseFilter.java

public HtmlParseFilter() {
    setNullableText(Boolean.TRUE);
    setLinkMatcherList(Collections.emptyList());
    setIgnore(Collections.emptyList());
}

From source file:com.cloudera.oryx.ml.param.GridSearch.java

/**
 * @param ranges ranges of hyperparameters to try, one per hyperparameters
 * @param howMany how many combinations of hyperparameters to return
 * @return combinations of concrete hyperparameter values. For example, for 5 parameters each
 *  with 3 values to try, the total number of combinations returned could be up to pow(3,5)
 *  or 243. The number could be less if the ranges do not actually have that many distinct
 *  values. If {@code howMany} is smaller than the total number of combinations, a random
 *  subset of all combinations are returned. The order is shuffled randomly. If no parameters
 *  are specified or {@code perParam} is 0, a single empty combination is returned.
 *//*w  w  w.  j  a v a2  s . c  o  m*/
static List<List<?>> chooseHyperParameterCombos(List<HyperParamValues<?>> ranges, int howMany) {
    // Put some reasonable upper limit on the number of combos
    Preconditions.checkArgument(howMany > 0 && howMany <= MAX_COMBOS);

    int numParams = ranges.size();
    int perParam = chooseValuesPerHyperParam(ranges, howMany);
    if (numParams == 0 || perParam == 0) {
        return Collections.singletonList(Collections.emptyList());
    }

    int howManyCombos = 1;
    List<List<?>> paramRanges = new ArrayList<>(numParams);
    for (HyperParamValues<?> range : ranges) {
        List<?> values = range.getTrialValues(perParam);
        paramRanges.add(values);
        howManyCombos *= values.size();
    }

    List<List<?>> allCombinations = new ArrayList<>(howManyCombos);
    for (int combo = 0; combo < howManyCombos; combo++) {
        List<Object> combination = new ArrayList<>(numParams);
        for (int param = 0; param < numParams; param++) {
            int whichValueToTry = combo;
            for (int i = 0; i < param; i++) {
                whichValueToTry /= paramRanges.get(i).size();
            }
            whichValueToTry %= paramRanges.get(param).size();
            combination.add(paramRanges.get(param).get(whichValueToTry));
        }
        allCombinations.add(combination);
    }

    if (howMany >= howManyCombos) {
        Collections.shuffle(allCombinations);
        return allCombinations;
    }
    RandomDataGenerator rdg = new RandomDataGenerator(RandomManager.getRandom());
    int[] indices = rdg.nextPermutation(howManyCombos, howMany);
    List<List<?>> result = new ArrayList<>(indices.length);
    for (int i = 0; i < indices.length; i++) {
        result.add(allCombinations.get(i));
    }
    Collections.shuffle(result);
    return result;
}

From source file:io.cloudslang.engine.data.SqlInQueryReader.java

public <T> List<T> read(Set<String> items, SqlInQueryCallback<T> callback) {
    Validate.notNull(callback);//from ww  w  .j  av a 2  s  .c  o m
    if (items == null) {
        return Collections.emptyList();
    } else {
        return readItems(items, callback);
    }
}

From source file:com.ok2c.lightmtp.SMTPReply.java

public SMTPReply(final int code, final SMTPCode enhancedCode, final List<String> lines) {
    super();//  w  w  w  . j  av  a2s  . co  m
    if (code <= 0) {
        throw new IllegalArgumentException("Code may not be nagtive or zero");
    }
    this.code = code;
    this.enhancedCode = enhancedCode;
    if (lines == null || lines.isEmpty()) {
        this.lines = Collections.emptyList();
    } else {
        this.lines = Collections.unmodifiableList(new ArrayList<String>(lines));
    }
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilter.java

static List<IssuePattern> loadPatterns(final Configuration configuration) {
    if (configuration == null) {
        return Collections.emptyList();
    }//from  w ww.  ja  v a2  s .c  om

    final String fileLocation = configuration.getString(CONFIG_FILE);
    if (StringUtils.isBlank(fileLocation)) {
        LOGGER.info("no ignore file configured for property: {}", CONFIG_FILE);
        return Collections.emptyList();
    }

    final File ignoreFile = new File(fileLocation);
    if (!ignoreFile.isFile()) {
        LOGGER.error("could not find ignore file: {}", ignoreFile);
        return Collections.emptyList();
    }

    FileInputStream fis = null;
    try {
        fis = new FileInputStream(ignoreFile);
        final List<IssuePattern> patterns = IssuePattern.parse(fis);
        LOGGER.info("loaded {} violation ignores from {}", patterns.size(), ignoreFile);
        return patterns;
    } catch (final Exception e) {
        throw new SonarException("could not load ignores for file: " + ignoreFile, e);
    } finally {
        IOUtils.closeQuietly(fis);
    }
}

From source file:comp.web.core.DataUtil.java

public List<Product> getProds(String cat, String prod, String from, String to) {
    logger.log(Level.FINER, "get prods with filter {0} {1} {2} {3}", new Object[] { cat, prod, from, to });

    if (StringUtils.isBlank(cat) && StringUtils.isBlank(prod) && StringUtils.isBlank(from)
            && StringUtils.isBlank(to)) {
        return Collections.emptyList();
    }/* ww w .j  a v a 2 s.c o  m*/

    String cat1 = StringUtils.stripToEmpty(cat) + "%";
    String prod1 = StringUtils.stripToEmpty(prod) + "%";
    double from1 = StringUtils.isNumeric(from) ? Double.parseDouble(from) : Double.MIN_VALUE;
    double to1 = StringUtils.isNumeric(to) ? Double.parseDouble(to) : Double.MAX_VALUE;

    EntityManager em = createEM();
    //        EntityTransaction tx = em.getTransaction();
    //        tx.begin();

    List<Product> products = em.createNamedQuery("priceList", Product.class).setParameter("cat", cat1)
            .setParameter("prod", prod1).setParameter("from", from1).setParameter("to", to1).getResultList();

    //        tx.commit();
    em.close();
    logger.log(Level.FINER, "get prods result size {0}", products.size());
    return products;
}

From source file:cz.cvut.portal.kos.services.support.ListPaginator.java

public static <T> ListPaginator<T> emptyList() {
    return new ListPaginator<T>(0, new DataFetcher<T>() {
        public List<T> fetchPage(int itemsPerPage, int startIndex) {
            return Collections.emptyList();
        }//from  www .j a va 2 s  .com
    });
}

From source file:jp.codic.plugins.netbeans.utils.CodicUtils.java

public static List<Translation> getTranslations(Codic codic, String selectedText) {
    if (selectedText == null || selectedText.isEmpty() || !containsFullwidth(selectedText)) {
        return Collections.emptyList();
    }//from ww w . ja v  a2  s.c om
    // params
    GetTranslationsParams params = new GetTranslationsParams(selectedText);
    GetTranslationsParams.Casing casing = codic.getCasing();
    if (casing != GetTranslationsParams.Casing.None) {
        params.casing(casing);
    }
    long projectId = codic.getProjectId();
    if (projectId > 0) {
        params.projectId(projectId);
    }

    return codic.getTranslations(params);
}

From source file:de.dentrassi.osgi.web.form.tags.FormValueTagSupport.java

protected List<BindingError> getErrors() {
    final BindingResult br = getBindingResult();
    if (br == null) {
        return Collections.emptyList();
    }//  w w  w .  ja va2  s.  c om
    return br.getLocalErrors();
}

From source file:com.michellemay.mappings.MappingsFactoryTest.java

@Test
public void testDefaultMappings() throws Exception {
    MappingsFactory f = new MappingsFactory(Collections.emptyList());

    assertEquals(f.getMappings().size(), 4);

    assertTrue(f.getMappings().containsKey("ISO-639-ALPHA-2"));
    assertEquals(f.getMappings().get("ISO-639-ALPHA-2").getMapping().get("en"), LocaleUtils.toLocale("en"));

    assertTrue(f.getMappings().containsKey("ISO-639-ALPHA-3"));
    assertEquals(f.getMappings().get("ISO-639-ALPHA-3").getMapping().get("eng"), LocaleUtils.toLocale("en"));

    assertTrue(f.getMappings().containsKey("LANGUAGE_TAGS"));
    assertEquals(f.getMappings().get("LANGUAGE_TAGS").getMapping().get("en-US"), LocaleUtils.toLocale("en_US"));

    assertTrue(f.getMappings().containsKey("ENGLISH_NAMES"));
    assertEquals(f.getMappings().get("ENGLISH_NAMES").getMapping().get("french"), LocaleUtils.toLocale("fr"));
}