List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:sk.lazyman.gizmo.util.GizmoUtils.java
public static <T extends Enum> IModel<List<T>> createReadonlyModelFromEnum(final Class<T> type) { return new AbstractReadOnlyModel<List<T>>() { @Override/*from ww w. j a va2s .c o m*/ public List<T> getObject() { List<T> list = new ArrayList<T>(); Collections.addAll(list, type.getEnumConstants()); return list; } }; }
From source file:ee.ria.DigiDoc.util.FileUtils.java
public static List<File> getContainers(Context context) { FilenameFilter containersOnly = new FilenameFilter() { @Override/*from w w w.j a v a2 s . c o m*/ public boolean accept(File dir, String name) { String lowerName = name.toLowerCase(); return lowerName.endsWith(".bdoc") || lowerName.endsWith(".ddoc") || lowerName.endsWith(".asice") || lowerName.endsWith(".sce") || lowerName.endsWith(".scs") || lowerName.endsWith(".edoc") || lowerName.endsWith(".adoc") || lowerName.endsWith(".asics"); } }; File[] containerFilesInBaseDir = baseStorageDir.listFiles(containersOnly); File[] containerFilesInDigiDocDir = FileUtils.getContainersDirectory(context).listFiles(containersOnly); if (containerFilesInBaseDir == null && containerFilesInDigiDocDir == null) { return Collections.emptyList(); } List<File> containers = new ArrayList<>(); if (containerFilesInBaseDir != null) { Collections.addAll(containers, containerFilesInBaseDir); } if (containerFilesInDigiDocDir != null) { Collections.addAll(containers, containerFilesInDigiDocDir); } return containers; }
From source file:net.firejack.platform.model.config.hibernate.HibernateFactoryBean.java
private void findDatabase() { List<String> xaDomains = new ArrayList<String>(); String xa = ConfigContainer.get("xa"); if (StringUtils.isNotBlank(xa)) { Collections.addAll(xaDomains, xa.split(";")); }//from w w w.j a va2s .c o m Properties properties = ConfigContainer.getProperties(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); String[] strings = key.split("\\."); if (strings.length == 3 && strings[0].equals("db")) { Database database = databases.get(strings[1]); if (database == null) { database = new Database(); databases.put(strings[1], database); } if (strings[2].equals("type")) { database.setType(DatabaseName.valueOf(value)); } else if (strings[2].equals("domains")) { List<String> domains = Arrays.asList(value.split(";")); database.setDomains(domains); for (String domain : domains) { if (domain.split("\\.").length == 3) database.setRoot(true); } } else if (strings[2].equals("url")) { database.setUrl(value); } else if (strings[2].equals("username")) { database.setUsername(value); } else if (strings[2].equals("password")) { database.setPassword(value); } } } Map<String, HibernateSupport> stories = context.getBeansOfType(HibernateSupport.class); for (Database database : databases.values()) { if (database.isRoot()) database.setStores(stories.values()); for (Iterator<Map.Entry<String, HibernateSupport>> iterator = stories.entrySet().iterator(); iterator .hasNext();) { Map.Entry<String, HibernateSupport> supportEntry = iterator.next(); HibernateSupport support = supportEntry.getValue(); if (database.addStore(support)) { iterator.remove(); } } } if (xaDomains.size() > 1) { for (Iterator<Map.Entry<String, Database>> iterator = databases.entrySet().iterator(); iterator .hasNext();) { Map.Entry<String, Database> entry = iterator.next(); List<String> domains = new ArrayList<String>(entry.getValue().getDomains()); for (Iterator<String> stringIterator = domains.iterator(); stringIterator.hasNext();) { if (xaDomains.contains(stringIterator.next())) { xaDatabases.put(entry.getKey(), entry.getValue()); stringIterator.remove(); } } if (domains.isEmpty()) iterator.remove(); } } }
From source file:com.felkertech.n.cumulustv.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d(TAG, "onCreate"); sm = new DriveSettingsManager(this); ActivityUtils.openIntroIfNeeded(this); final ChannelDatabase channelDatabase = ChannelDatabase.getInstance(MainActivity.this); Fabric.with(this, new Crashlytics()); if (AppUtils.isTV(this)) { // Go to tv activity Intent leanbackIntent = new Intent(this, LeanbackActivity.class); leanbackIntent.setFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); startActivity(leanbackIntent);//from w w w . ja v a 2s . c o m } findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityUtils.openPluginPicker(true, MainActivity.this); } }); findViewById(R.id.view).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String[] channelnames = channelDatabase.getChannelNames(); if (channelnames.length == 0) { new MaterialDialog.Builder(MainActivity.this).title(R.string.no_channels) .content(R.string.no_channels_find).positiveText(R.string.ok).negativeText(R.string.no) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); dialog.cancel(); findViewById(R.id.suggested).performClick(); } }).show(); } else { try { displayChannelPicker(channelDatabase.getJsonChannels(), channelnames); } catch (JSONException e) { e.printStackTrace(); } } } }); findViewById(R.id.view_genres).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Generate genres Set<String> genreSet = new HashSet<>(); try { for (JsonChannel jsonChannel : channelDatabase.getJsonChannels()) { Collections.addAll(genreSet, jsonChannel.getGenres()); } final String[] genreArray = genreSet.toArray(new String[genreSet.size()]); new MaterialDialog.Builder(MainActivity.this).title(R.string.select_genres).items(genreArray) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) { // Now only get certain channels String selectedGenre = genreArray[position]; List<JsonChannel> jsonChannelList = new ArrayList<>(); List<String> channelNames = new ArrayList<>(); try { for (JsonChannel jsonChannel : channelDatabase.getJsonChannels()) { if (jsonChannel.getGenresString().contains(selectedGenre)) { jsonChannelList.add(jsonChannel); channelNames .add(jsonChannel.getNumber() + " " + jsonChannel.getName()); } } displayChannelPicker(jsonChannelList, channelNames.toArray(new String[channelNames.size()]), selectedGenre); } catch (JSONException e) { e.printStackTrace(); } } }).show(); } catch (JSONException e) { e.printStackTrace(); } } }); findViewById(R.id.suggested).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityUtils.openSuggestedChannels(MainActivity.this, gapi); } }); findViewById(R.id.gdrive).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gapi = ActivityUtils.GoogleDrive.connect(MainActivity.this); } }); findViewById(R.id.more_actions).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { moreClick(); } }); }
From source file:org.esbtools.eventhandler.lightblue.DocumentEventEntity.java
public void addSurvivorOfIds(@Nullable String... ids) { if (ids == null) return;/*w ww.j a va 2 s. c o m*/ if (survivorOfIds == null) { survivorOfIds = new HashSet<>(); } Collections.addAll(survivorOfIds, ids); }
From source file:edu.wpi.checksims.submission.Submission.java
/** * Recursively find all files matching in a directory. * * @param directory Directory to search in * @param glob Match pattern used to identify files to include * @return List of all matching files in this directory and subdirectories *///from ww w . j a v a2 s . co m static Set<File> getAllMatchingFiles(File directory, String glob, boolean recursive) throws NoSuchFileException, NotDirectoryException { checkNotNull(directory); checkNotNull(glob); checkArgument(!glob.isEmpty(), "Glob pattern cannot be empty"); Set<File> allFiles = new HashSet<>(); Logger logs = LoggerFactory.getLogger(Submission.class); if (recursive) { logs.trace("Recursively traversing directory " + directory.getName()); } // Add this directory Collections.addAll(allFiles, getMatchingFilesFromDir(directory, glob)); // Get subdirectories File[] subdirs = directory.listFiles(File::isDirectory); // Recursively call on all subdirectories if specified if (recursive) { for (File subdir : subdirs) { allFiles.addAll(getAllMatchingFiles(subdir, glob, true)); } } return allFiles; }
From source file:com.baasbox.android.BaasUser.java
private static void readStringSet(Parcel p, Set<String> set) { int size = p.readInt(); String[] arr = new String[size]; p.readStringArray(arr);/* ww w . j a v a2 s .c o m*/ Collections.addAll(set, arr); }
From source file:com.aionemu.gameserver.services.reward.BonusService.java
QuestItems getCraftBonus(Player player, QuestTemplate questTemplate) { BonusItemGroup[] groups = itemGroups.getCraftGroups(); CraftGroup group = null;/*from w w w . ja va 2s .c om*/ ItemRaceEntry[] allRewards = null; while (groups != null && groups.length > 0 && group == null) { group = (CraftGroup) getRandomGroup(groups); if (group == null) { break; } allRewards = group.getRewards(questTemplate.getCombineSkill(), questTemplate.getCombineSkillPoint()); if (allRewards.length == 0) { List<BonusItemGroup> temp = new ArrayList<BonusItemGroup>(); Collections.addAll(temp, groups); temp.remove(group); group = null; groups = temp.toArray(new BonusItemGroup[0]); } } if (group == null) // probably all chances set to 0 { return null; } List<ItemRaceEntry> finalList = new ArrayList<ItemRaceEntry>(); for (int i = 0; i < allRewards.length; i++) { ItemRaceEntry r = allRewards[i]; if (!r.checkRace(player.getCommonData().getRace())) { continue; } finalList.add(r); } if (finalList.isEmpty()) { return null; } int itemIndex = Rnd.get(finalList.size()); int itemCount = 1; ItemRaceEntry reward = finalList.get(itemIndex); if (reward instanceof CraftItem) { itemCount = Rnd.get(3, 5); } return new QuestItems(reward.getId(), itemCount); }
From source file:edu.kit.dama.staging.adapters.DefaultIngestInformationServiceAdapter.java
@Override public List<IngestInformation> getIngestsByStatus(INGEST_STATUS pStatus, IAuthorizationContext pContext) throws ServiceAdapterException { LOGGER.debug("Getting all ingests by status {}", pStatus); List<IngestInformation> result = new LinkedList<>(); List<IngestInformation> queryResult = IngestInformationServiceLocal.getSingleton() .getIngestInformationByStatus(pStatus.getId(), 0, Integer.MAX_VALUE, pContext); if (queryResult != null) { LOGGER.debug("Query for ingests by status {} returned '{}' results", pStatus, queryResult.size()); Collections.addAll(result, queryResult.toArray(new IngestInformation[queryResult.size()])); } else {//from ww w . j av a2 s.c o m LOGGER.debug("Query for ingests by status {} returned no results", pStatus); } return result; }
From source file:com.flipkart.flux.api.StateMachineDefinition.java
public void addEventDatas(EventData[] events) { Collections.addAll(this.eventData, events); }