List of usage examples for java.util List addAll
boolean addAll(Collection<? extends E> c);
From source file:com.dianping.squirrel.client.util.ClassUtils.java
public static Field[] getDeclaredFields(Class<?> clazz) { Assert.notNull(clazz);/*from w w w .jav a 2 s . c o m*/ List<Field> fields = new ArrayList<Field>(); for (Class<?> currentClazz = clazz; currentClazz != Object.class; currentClazz = currentClazz .getSuperclass()) { fields.addAll(Arrays.asList(currentClazz.getDeclaredFields())); } return fields.toArray(new Field[fields.size()]); }
From source file:com.redhat.lightblue.assoc.ResultDoc.java
/** * Returns all child references to a given node for all the docs in the list *//*from www. ja v a 2 s. c om*/ public static List<ChildDocReference> getChildren(List<ResultDoc> docs, QueryPlanNode dest) { List<ChildDocReference> ret = new ArrayList<>(); for (ResultDoc x : docs) { List<ChildDocReference> l = x.getChildren(dest); if (l != null) ret.addAll(l); } return ret; }
From source file:com.spectralogic.ds3autogen.utils.Helper.java
/** * Sorts a list of Arguments by name. Used for sorting constructor arguments for consistency. * @param arguments List of Arguments/*from w w w. ja va 2 s . c o m*/ * @return Sorted list of Arguments */ public static ImmutableList<Arguments> sortConstructorArgs(final ImmutableList<Arguments> arguments) { final List<Arguments> sortable = new ArrayList<>(); sortable.addAll(arguments); Collections.sort(sortable, new CustomArgumentComparator()); final ImmutableList.Builder<Arguments> builder = ImmutableList.builder(); builder.addAll(sortable); return builder.build(); }
From source file:forge.ai.AiProfileUtil.java
/** * Returns an array of strings containing all available profiles including * the special "Random" profiles.// ww w .ja va2 s.c om * @return ArrayList<String> - an array list of strings containing all * available profiles including special random profile tags. */ public static List<String> getProfilesDisplayList() { final List<String> availableProfiles = new ArrayList<String>(); availableProfiles.add(AI_PROFILE_RANDOM_MATCH); availableProfiles.add(AI_PROFILE_RANDOM_DUEL); availableProfiles.addAll(getAvailableProfiles()); return availableProfiles; }
From source file:eu.delving.stats.ChartHelper.java
private static List<Stats.Counter> sort(Collection<Stats.Counter> original) { List<Stats.Counter> sorted = new ArrayList<Stats.Counter>(original.size()); sorted.addAll(original); Collections.sort(sorted, new Comparator<Stats.Counter>() { @Override//w w w. j a v a 2 s. com public int compare(Stats.Counter a, Stats.Counter b) { return Integer.valueOf(a.value).compareTo(Integer.valueOf(b.value)); } }); return sorted; }
From source file:net.elsched.utils.SettingsBinder.java
/** * Bind configuration parameters into Guice Module. * /*from www . j av a 2 s .c om*/ * @return a Guice module configured with setting support. * @throws ConfigurationException * on configuration error */ public static Module bindSettings(String propertiesFileKey, Class<?>... settingsArg) throws ConfigurationException { final CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); String propertyFile = config.getString(propertiesFileKey); if (propertyFile != null) { config.addConfiguration(new PropertiesConfiguration(propertyFile)); } List<Field> fields = new ArrayList<Field>(); for (Class<?> settings : settingsArg) { fields.addAll(Arrays.asList(settings.getDeclaredFields())); } // Reflect on settings class and absorb settings final Map<Setting, Field> settings = new LinkedHashMap<Setting, Field>(); for (Field field : fields) { if (!field.isAnnotationPresent(Setting.class)) { continue; } // Validate target type SettingTypeValidator typeHelper = supportedSettingTypes.get(field.getType()); if (typeHelper == null || !typeHelper.check(field.getGenericType())) { throw new IllegalArgumentException(field.getType() + " is not one of the supported setting types"); } Setting setting = field.getAnnotation(Setting.class); settings.put(setting, field); } // Now validate them List<String> missingProperties = new ArrayList<String>(); for (Setting setting : settings.keySet()) { if (setting.defaultValue().isEmpty()) { if (!config.containsKey(setting.name())) { missingProperties.add(setting.name()); } } } if (missingProperties.size() > 0) { StringBuilder error = new StringBuilder(); error.append("The following required properties are missing from the server configuration: "); error.append(Joiner.on(", ").join(missingProperties)); } // bundle everything up in an injectable guice module return new AbstractModule() { @Override protected void configure() { // We must iterate the settings a third time when binding. // Note: do not collapse these loops as that will damage // early error detection. The runtime is still O(n) in setting // count. for (Map.Entry<Setting, Field> entry : settings.entrySet()) { Class<?> type = entry.getValue().getType(); Setting setting = entry.getKey(); if (int.class.equals(type)) { Integer defaultValue = null; if (!setting.defaultValue().isEmpty()) { defaultValue = Integer.parseInt(setting.defaultValue()); } bindConstant().annotatedWith(Names.named(setting.name())) .to(config.getInteger(setting.name(), defaultValue)); } else if (boolean.class.equals(type)) { Boolean defaultValue = null; if (!setting.defaultValue().isEmpty()) { defaultValue = Boolean.parseBoolean(setting.defaultValue()); } bindConstant().annotatedWith(Names.named(setting.name())) .to(config.getBoolean(setting.name(), defaultValue)); } else if (String.class.equals(type)) { bindConstant().annotatedWith(Names.named(setting.name())) .to(config.getString(setting.name(), setting.defaultValue())); } else { String[] value = config.getStringArray(setting.name()); if (value.length == 0 && !setting.defaultValue().isEmpty()) { value = setting.defaultValue().split(","); } bind(new TypeLiteral<List<String>>() { }).annotatedWith(Names.named(setting.name())).toInstance(ImmutableList.copyOf(value)); } } } }; }
From source file:com.lixiaocong.util.VideoFileHelper.java
public static List<File> findAllVideos(File file, String[] types) { List<File> ret = new LinkedList<>(); if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) for (File subFile : files) { List<File> subFiles = findAllVideos(subFile, types); ret.addAll(subFiles); }/*from w w w . j a v a2 s .c o m*/ } else { String name = file.getName(); for (String type : types) if (name.endsWith(type)) { ret.add(file); break; } } return ret; }
From source file:Main.java
/** * Scans a node and all of its children for nodes of a particular type. * //from w w w . j a va 2s . com * @param parent * The parent node * @param nodeName * The node name to search for * @return a List of all the nodes found matching the nodeName under the parent */ public static List<Node> getNodes(final Node parent, final String nodeName) { final List<Node> nodes = new ArrayList<Node>(); final NodeList children = parent.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { final Node child = children.item(i); if (child.getNodeName().equals(nodeName)) { nodes.add(child); } else { nodes.addAll(getNodes(child, nodeName)); } } return nodes; }
From source file:com.formkiq.core.form.FormFinder.java
/** * Find {@link FormJSONField} by type.//from w w w. j a va2s .c o m * * @param form {@link FormJSON} * @param type {@link FormJSONFieldType} * @return {@link Optional} of {@link FormJSONField} */ public static List<FormJSONField> findFieldsByType(final FormJSON form, final FormJSONFieldType type) { List<FormJSONField> fields = new ArrayList<>(); for (FormJSONSection section : form.getSections()) { fields.addAll(findFieldsByType(section, type)); } return fields; }
From source file:blog.identify.IdentifyMultipleFacesExample.java
private static java.util.List<BufferedImage> extractImagesFromPeople(People people) { java.util.List<BufferedImage> images = new ArrayList<>(); java.util.List<People.SimplePerson> simplePersons = people.simplePersons(); images.addAll(simplePersons.parallelStream() .map(simplePerson -> BlogHelper.loadAndNameCandidateImages(simplePerson.personImages.get(0))) .collect(Collectors.toList())); return images; }