List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:com.izforge.izpack.panels.target.TargetPanelHelper.java
/** * Returns the installation path for the specified platform name. * <p/>/* w w w.java2s. co m*/ * This looks for a variable named {@code TargetPanel.dir.<platform name>}. If none is found, it searches the * parent platforms, in a breadth-first manner. * * @param installData the installation data * @param name the platform name * @return the default path, or {@code null} if none is found */ private static String getTargetPanelDir(InstallData installData, Platform.Name name) { String path = null; List<Platform.Name> queue = new ArrayList<Platform.Name>(); queue.add(name); while (!queue.isEmpty()) { name = queue.remove(0); path = installData.getVariable(PREFIX + name.toString().toLowerCase()); if (path != null) { break; } Collections.addAll(queue, name.getParents()); } return path; }
From source file:org.solmix.runtime.cm.support.SpringConfigureUnitManager.java
public List<Resource> getConfigureResource(String dir) { List<Resource> resources = new ArrayList<Resource>(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver( Thread.currentThread().getContextClassLoader()); try {//ww w . j ava 2 s . c o m Collections.addAll(resources, resolver.getResources(dir)); } catch (IOException e) { logger.error("IOException", e); } return resources; }
From source file:edu.cmu.tetrad.cli.util.Args.java
public static String[] removeFlags(String[] args, String... flags) { String[] arguments = new String[args.length - 2]; Set<String> options = new HashSet<>(); Collections.addAll(options, flags); int index = 0; for (String arg : args) { if (arg.startsWith("--")) { arg = arg.substring(2, arg.length()); if (options.contains(arg)) { continue; }/*from www . j a va2 s. c om*/ } else if (arg.startsWith("-")) { arg = arg.substring(1, arg.length()); if (options.contains(arg)) { continue; } } arguments[index++] = arg; } return arguments; }
From source file:com.rockagen.commons.util.ClassUtil.java
/** * obtain methods list of specified class If recursively is true, obtain * methods from all class hierarchy/*from www . j av a 2 s . c o m*/ * * @param clazz class * where fields are searching * @param recursively * param * @return array of methods */ public static Method[] getDeclaredMethods(Class<?> clazz, boolean recursively) { List<Method> methods = new LinkedList<Method>(); Method[] declaredMethods = clazz.getDeclaredMethods(); Collections.addAll(methods, declaredMethods); Class<?> superClass = clazz.getSuperclass(); if (superClass != null && recursively) { Method[] declaredMethodsOfSuper = getDeclaredMethods(superClass, true); if (declaredMethodsOfSuper.length > 0) Collections.addAll(methods, declaredMethodsOfSuper); } return methods.toArray(new Method[methods.size()]); }
From source file:com.thoughtworks.studios.journey.cspmining.SuffixTree.java
public List<String> pathTo(TreeNode node) { List<String> path = new LinkedList<>(); path.add(root.getNames()[0]);/*w w w .jav a 2s . c o m*/ List<TreeNode> suffix = node.pathToRoot(); for (TreeNode treeNode : reverse(suffix)) { Collections.addAll(path, treeNode.getNames()); } return path; }
From source file:cognition.common.model.Individual.java
public List<String> getSeparatedForeNames() { if (getForeNames() == null) { return new ArrayList<>(); }/* w w w. j a va2s. c o m*/ List<String> names = new ArrayList<>(); for (String name : getForeNames()) { if (StringUtils.isBlank(name)) { continue; } String[] nameSplit = name.split(" "); Collections.addAll(names, nameSplit); } return names; }
From source file:me.oriley.homage.Homage.java
public void refreshLibraries() { List<Library> newLibraries = new ArrayList<>(); if (mAssetPaths != null) { for (String assetPath : mAssetPaths) { if (TextUtils.isEmpty(assetPath)) { Log.w(TAG, "Empty asset path passed, ignoring"); continue; }//from w ww . j a v a 2 s . c o m Library[] libs = getLibraryArray(mContext, assetPath); if (libs != null) { Collections.addAll(newLibraries, libs); } } } if (mResourceIds != null) { for (int resourceId : mResourceIds) { if (resourceId <= 0) { Log.w(TAG, "Invalid resource ID passed: " + resourceId + ", ignoring"); continue; } Library[] libs = getLibraryArray(mContext, resourceId); if (libs != null) { Collections.addAll(newLibraries, libs); } } } if (newLibraries.isEmpty()) { Log.w(TAG, "No libraries found"); return; } for (Library library : newLibraries) { String licenseCode = library.getLicenseCode(); License license; if (!TextUtils.isEmpty(licenseCode)) { license = getLicense(licenseCode); if (license == null) { license = mLicenses.get(UNRECOGNISED.name()); } } else { license = mLicenses.get(NONE.name()); } library.setLicense(license); String icon = library.getLibraryIcon(); if (!TextUtils.isEmpty(icon)) { if (icon.contains("://")) { library.setIconUri(icon); } else { int iconRes = getResourceId(mContext, icon, ResourceType.DRAWABLE); if (iconRes <= 0) { iconRes = getResourceId(mContext, icon, ResourceType.MIPMAP); } if (iconRes <= 0) { iconRes = android.R.drawable.sym_def_app_icon; } library.setIconResource(iconRes); } } } mLibraries = Collections.unmodifiableList(newLibraries); }
From source file:com.example.app.profile.ui.user.UserMembershipManagement.java
/** * Instantiate a new instance of UserMembershipManagement * * @param user the User for which this manager is managing the Roles * @param profiles the profiles for which this manager is managing the Roles -- must have at least one *///from ww w. j ava 2 s. c o m public UserMembershipManagement(@Nonnull User user, Profile... profiles) { super(); Preconditions.checkNotNull(user, "User was null, this should not happen."); Preconditions.checkArgument(profiles.length > 0, "Need at least one Profile for Role Management."); _user = user; Collections.addAll(_profiles, profiles); addClassName("user-roles"); }
From source file:de.tor.tribes.ui.views.DSWorkbenchFarmManager.java
public static Village[] getSelectedFarmGroup() { List<Village> pactiveFarmGroup = new ArrayList<>(); String tag = DSWorkbenchFarmManager.SelectedFarmGroup; if (tag.equals("Alle")) { Collections.addAll(pactiveFarmGroup, GlobalOptions.getSelectedProfile().getTribe().getVillageList()); } else {/*from ww w . ja va 2s .c om*/ for (Integer id : TagManager.getSingleton().getTagByName(tag).getVillageIDs()) { pactiveFarmGroup.add(DataHolder.getSingleton().getVillagesById().get(id)); } } return pactiveFarmGroup.toArray(new Village[pactiveFarmGroup.size()]); }
From source file:jp.aegif.nemaki.util.impl.PropertyManagerImpl.java
/** * Override is not supported for update/*from w w w. ja v a2 s . com*/ */ @Override public void addValue(String key, String value) { String currentVal = config.getProperty(key); String[] currentVals = (StringUtils.isEmpty(currentVal)) ? new String[0] : currentVal.split(","); List<String> valList = new ArrayList<String>(); Collections.addAll(valList, currentVals); valList.add(0, value); String newVal = StringUtils.join(valList.toArray(), ","); config.setProperty(key, newVal); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL url = classLoader.getResource(propertiesFile); try { config.store(new FileOutputStream(new File(url.toURI())), null); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } }