List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:fi.jumi.actors.maven.GenerateEventStubsMojo.java
private static Class<?> loadFromClassPath(String className, List<File> classpath) throws ClassNotFoundException { return loadFromClasspath(className, classpath.toArray(new File[classpath.size()])); }
From source file:Main.java
public static String[] insertAtLast(String[] resource, String str, int addQuan) { List<String> list = new ArrayList<>(); for (int i = 0; i < resource.length; i++) { list.add(resource[i]);// w ww . ja v a 2s. co m } for (int i = 0; i < addQuan - resource.length; i++) { list.add(str + (i + resource.length)); } String[] result = list.toArray(resource); return result; }
From source file:com.iadams.sonarqube.puppet.Puppet.java
private static String[] filterEmptyStrings(String[] stringArray) { List<String> nonEmptyStrings = Lists.newArrayList(); for (String string : stringArray) { if (StringUtils.isNotBlank(string.trim())) { nonEmptyStrings.add(string.trim()); }/*w ww .j av a 2 s . c o m*/ } return nonEmptyStrings.toArray(new String[nonEmptyStrings.size()]); }
From source file:ClassUtil.java
/** * Retrieving fields list of specified class and which * are annotated by incoming annotation class * If recursively is true, retrieving fields from all class hierarchy * * @param clazz - where fields are searching * @param annotationClass - specified annotation class * @param recursively param//from w ww . j a va2 s . co m * @return list of annotated fields */ public static Field[] getAnnotatedDeclaredFields(Class clazz, Class<? extends Annotation> annotationClass, boolean recursively) { Field[] allFields = getDeclaredFields(clazz, recursively); List<Field> annotatedFields = new LinkedList<Field>(); for (Field field : allFields) { if (field.isAnnotationPresent(annotationClass)) annotatedFields.add(field); } return annotatedFields.toArray(new Field[annotatedFields.size()]); }
From source file:Main.java
public static Element[] getDirectElements(Element parent, String name) { NodeList children = parent.getChildNodes(); List<Element> result = new LinkedList<>(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equals(name)) { result.add((Element) node); }//from w ww . ja v a 2 s . c o m } return result.toArray(new Element[0]); }
From source file:Main.java
public static Method[] getSelfMethod(Object o) { Class c = o.getClass();/* w w w. jav a2 s.co m*/ Method[] ms = o.getClass().getMethods(); List list = new ArrayList(); for (Method m : ms) { int mod = m.getModifiers(); if (m.getDeclaringClass().equals(c) && Modifier.isPublic(mod) && !Modifier.isStatic(mod)) { list.add(m); } } return (Method[]) list.toArray(new Method[0]); }
From source file:es.udc.gii.common.eaf.algorithm.fitness.FitnessUtil.java
/** * This method receive a list of individuals and return an array containing * the fitness value of each individual. * @param individuals a list of individuals. * @return an array containing the fitness value of each individual in * the list./*ww w. j a v a 2s.c om*/ */ private static double[] getArrayFitness(List<Individual> individuals) { Individual[] arrayIndividuals = new Individual[individuals.size()]; double[] arrayFitness = new double[individuals.size()]; arrayIndividuals = individuals.toArray(arrayIndividuals); for (int i = 0; i < arrayIndividuals.length; i++) { arrayFitness[i] = arrayIndividuals[i].getFitness(); } return arrayFitness; }
From source file:com.creditcloud.tag.utils.TagUtils.java
/** * seperator??Tag/* w w w. j ava 2s. c o m*/ * * @param tagsString * @param seperator * @return */ public static Tag[] parseTags(String tagsString, String seperator) { if (StringUtils.isBlank(tagsString) || StringUtils.isBlank(seperator)) { return TagConstant.EMPTY_ARRAY; } String[] tagStrings; if (tagsString.contains(seperator)) { tagStrings = tagsString.split(seperator); } else { tagStrings = new String[] { tagsString }; } List<Tag> tags = new ArrayList<>(); for (String tagString : tagStrings) { Tag tag = toTag(tagString); if (tag != null) { tags.add(tag); } } return tags.toArray(new Tag[tags.size()]); }
From source file:com.anhth12.lambda.common.text.TextUtils.java
public static String[] parsePMMLDelimited(String delimited) { // Although you'd think ignoreSurroundingSpaces helps here, won't work with space // delimiter. So manually trim below. String[] rawResult = doParseDelimited(delimited, formatForDelimiter(' ')); List<String> resultList = new ArrayList<>(); for (String raw : rawResult) { if (!raw.isEmpty()) { resultList.add(raw);/*from w w w. j a va 2 s. c om*/ } } return resultList.toArray(new String[resultList.size()]); }
From source file:com.zxy.commons.mongodb.MongodbUtils.java
/** * ?//from w ww. ja va2 s .c o m * * @param params params * @return Query */ public static Query getQuery(Map<String, Object> params) { if (params == null || params.isEmpty()) { return null; } List<Criteria> criterias = new ArrayList<>(); for (Map.Entry<String, Object> entry : params.entrySet()) { criterias.add(Criteria.where(entry.getKey()).is(entry.getValue())); } return new Query(new Criteria().andOperator(criterias.toArray(new Criteria[params.size()]))); }