Example usage for java.util List toArray

List of usage examples for java.util List toArray

Introduction

In this page you can find the example usage for java.util List toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

Usage

From source file:com.yunmel.syncretic.utils.commons.StrUtils.java

public static Long[] toLongArray(String idStr, String separator) {
    if (StringUtils.isNotBlank(idStr)) {
        String[] ids = idStr.split(separator);
        List<Long> values = Lists.newArrayList();
        for (String id : ids) {
            if (StringUtils.isNotBlank(id)) {
                values.add(Long.valueOf(id));
            }/*from w w w.j a  va2  s. com*/
        }
        return values.toArray(new Long[0]);
    }
    return null;
}

From source file:Main.java

public static String[] splitByCamelCase(String name) {
    List<String> parts = new ArrayList<String>();
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < name.length(); i++) {
        if (i > 0 && Character.isUpperCase(name.charAt(i))) {
            parts.add(b.toString());//from  w w  w . j  av a 2s.  c o m
            b = new StringBuilder();
        }
        b.append(Character.toLowerCase(name.charAt(i)));
    }
    parts.add(b.toString());
    return parts.toArray(new String[] {});
}

From source file:com.googlecode.jtiger.modules.ecside.table.calc.CalcUtils.java

public static String[] getFirstCalcColumnTitles(TableModel model) {
    List values = new ArrayList();

    Column column = model.getColumnHandler().getFirstCalcColumn();
    String calcs[] = column.getCalc();
    for (int i = 0; i < calcs.length; i++) {
        values.add(getFirstCalcColumnTitleByPosition(model, i));
    }//from  w  w  w .jav a  2 s  .  com

    return (String[]) values.toArray(new String[values.size()]);
}

From source file:com.igormaznitsa.j2z80.utils.Utils.java

/**
 * Concatenate string arrays into a string array
 * @param arrays string arrays, must not be null
 * @return a string array contains all content of arrays as the arguments
 *//*from ww w  .  j  a v  a  2  s. c om*/
public static String[] concatStringArrays(final String[]... arrays) {
    Assert.assertNotNull("Concatenated arrays must not contain null", (Object[]) arrays);
    final List<String> result = new ArrayList<String>();
    for (final String[] arg : arrays) {
        for (final String s : arg) {
            result.add(s);
        }
    }
    return result.toArray(new String[result.size()]);
}

From source file:com.htmlhifive.tools.jslint.util.ConfigBeanUtil.java

/**
 * ??????????.<br>// www.  j a  v a 2 s. c  om
 * 
 * @param clazz ??
 * @return 
 */
public static CheckOption[] getJsHintOptionFromDefault(Class<?> clazz) {

    JSHintDefaultOptions[] options = JSHintDefaultOptions.values();
    List<CheckOption> optionList = new ArrayList<CheckOption>();
    for (JSHintDefaultOptions option : options) {
        if (option.getClazz() == clazz) {
            optionList.add(option.convertToOption());
        }
    }
    return (CheckOption[]) optionList.toArray(new CheckOption[optionList.size()]);
}

From source file:com.htmlhifive.tools.jslint.util.ConfigBeanUtil.java

/**
 * ??????????.<br>//  ww  w.  j av  a  2 s. co  m
 * 
 * @param clazz ??
 * @return 
 */
public static CheckOption[] getJsLintOptionFromDefault(Class<?> clazz) {

    JSLintDefaultOptions[] options = JSLintDefaultOptions.values();
    List<CheckOption> optionList = new ArrayList<CheckOption>();
    for (JSLintDefaultOptions option : options) {
        if (option.getClazz() == clazz) {
            optionList.add(option.convertToOption());
        }
    }
    return (CheckOption[]) optionList.toArray(new CheckOption[optionList.size()]);
}

From source file:com.hengyi.japp.execution.Util.java

public static void queryCommand(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<Customer> root,
        CustomerQueryCommand command) {//from ww  w  . j  a va2  s.com
    List<Predicate> ps = Lists.newArrayListWithCapacity(2);
    ps.add(cb.equal(root.get(Customer_.deleteFlag), command.isDeleteFlag()));
    if (!isBlank(command.getName())) {
        ps.add(cb.like(root.get(Customer_.name), command.getNameQuery()));
    }
    cq.where(ps.toArray(new Predicate[ps.size()]));
}

From source file:io.seqware.pipeline.whitestar.WhiteStarTest.java

protected static void createAndRunWorkflow(Path settingsFile, boolean metadata) throws Exception, IOException {
    // create a helloworld
    Path tempDir = Files.createTempDirectory("tempTestingDirectory");
    PluginRunner it = new PluginRunner();
    String SEQWARE_VERSION = it.getClass().getPackage().getImplementationVersion();
    Assert.assertTrue("unable to detect seqware version", SEQWARE_VERSION != null);
    Log.info("SeqWare version detected as: " + SEQWARE_VERSION);
    String archetype = "java-workflow";
    String workflow = "seqware-archetype-" + archetype;
    String workflowName = workflow.replace("-", "");
    // generate and install archetypes to local maven repo
    String command = "mvn archetype:generate -DarchetypeCatalog=local -Dpackage=com.seqware.github -DgroupId=com.github.seqware -DarchetypeArtifactId="
            + workflow + " -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=com.github.seqware -DartifactId="
            + workflow + " -Dworkflow-name=" + workflowName + " -B -Dgoals=install";
    String genOutput = ITUtility.runArbitraryCommand(command, 0, tempDir.toFile());
    Log.info(genOutput);/*from  w w w .  ja va2s.  co  m*/
    // install the workflows to the database and record their information
    File workflowDir = new File(tempDir.toFile(), workflow);
    File targetDir = new File(workflowDir, "target");
    final String workflow_name = "Workflow_Bundle_" + workflowName + "_1.0-SNAPSHOT_SeqWare_" + SEQWARE_VERSION;
    File bundleDir = new File(targetDir, workflow_name);

    Map environment = EnvironmentUtils.getProcEnvironment();
    environment.put("SEQWARE_SETTINGS", settingsFile.toAbsolutePath().toString());

    // save system environment variables
    Map<String, String> env = System.getenv();
    try {
        // override for launching
        Utility.set(environment);
        List<String> cmd = new ArrayList<>();
        cmd.add("bundle");
        cmd.add("launch");
        cmd.add("--dir");
        cmd.add(bundleDir.getAbsolutePath());
        if (!metadata) {
            cmd.add("--no-metadata");
        }
        Main.main(cmd.toArray(new String[cmd.size()]));
    } finally {
        Utility.set(env);
    }

}

From source file:com.mmj.app.common.file.ExcelUtils.java

public static Field[] getAllFields(List<Field> fields, Class<?> type) {
    for (Field field : type.getDeclaredFields()) {
        fields.add(field);//from  w  w w  .  j  av a2  s  .c o  m
    }
    if (type.getSuperclass() != null) {
        fields.addAll(Arrays.asList(getAllFields(fields, type.getSuperclass())));
    }
    return fields.toArray(new Field[fields.size()]);
}

From source file:com.espertech.esper.epl.expression.ExprSubselectNode.java

public static ExprSubselectNode[] toArray(List<ExprSubselectNode> subselectNodes) {
    if (subselectNodes.isEmpty()) {
        return EMPTY_SUBSELECT_ARRAY;
    }//from  w  ww.j  av a 2s.c  o m
    return subselectNodes.toArray(new ExprSubselectNode[subselectNodes.size()]);
}