List of usage examples for java.util List remove
E remove(int index);
From source file:com.smash.revolance.ui.comparator.page.PageMatchMaker.java
public static PageBean findPageByContentValue(Collection<PageBean> pages, List<String> contentValues) { for (PageBean page : pages) { List<String> pageContentValues = getContentValue(page.getContent()); for (String value : contentValues) { if (pageContentValues.contains(value)) { pageContentValues.remove(value); }// w w w.java 2s .co m if (pageContentValues.isEmpty()) { break; } } if (pageContentValues.isEmpty()) { return page; } } return null; }
From source file:com.cdd.bao.template.SchemaUtil.java
public static Schema mergeSchema(Schema schema, Schema extra, List<String> log) { schema = schema.clone();/*from ww w. java 2 s . co m*/ List<Schema.Group> stack = new ArrayList<>(); stack.add(extra.getRoot()); while (stack.size() > 0) { Schema.Group grp = stack.remove(0); for (int n = 0; n < grp.subGroups.size(); n++) stack.add(n, grp.subGroups.get(n)); Schema.Group dstgrp = schema.findGroup(grp); if (dstgrp == null) { Schema.Group parent = schema.findGroup(grp.parent); dstgrp = new Schema.Group(parent, grp.name); dstgrp.descr = grp.descr; parent.subGroups.add(dstgrp); log.add("Added new group: [" + grp.name + "]"); } for (Schema.Assignment assn : grp.assignments) { Schema.Assignment dstassn = schema.findAssignment(assn); if (dstassn == null) { dstassn = assn.clone(); dstassn.parent = dstgrp; dstgrp.assignments.add(dstassn); log.add("Added new assignment: [" + assn.name + "]"); } gotval: for (Schema.Value val : assn.values) { for (Schema.Value dstval : dstassn.values) if (val.equals(dstval)) continue gotval; dstassn.values.add(val); if (val.uri.length() > 0) log.add("Assignment [" + assn.name + "] added new value <" + val.uri + ">: [" + val.name + "]"); else log.add("Assignment [" + assn.name + "] added new literal \"" + val.name + "\""); } } } gotassay: for (int n = 0; n < extra.numAssays(); n++) { Schema.Assay assay = extra.getAssay(n); if (assay.annotations.size() == 0) continue; for (int i = 0; i < schema.numAssays(); i++) { Schema.Assay dstass = schema.getAssay(i); if (!assay.name.equals(dstass.name)) continue; if (assay.equals(dstass)) continue gotassay; if (dstass.annotations.size() == 0) { schema.setAssay(i, assay.clone()); log.add("Assay [" + assay.name + "]: replaced blank entry"); continue gotassay; } else if (!assay.equals(dstass)) { schema.insertAssay(i + 1, assay.clone()); log.add("Assay [" + assay.name + "]: inserted different version"); continue gotassay; } } schema.appendAssay(assay.clone()); log.add("Added new assay [" + assay.name + "]"); } return schema; }
From source file:com.github.pemapmodder.pocketminegui.gui.startup.installer.cards.ServerSetupCard.java
@SuppressWarnings("unchecked") private static Map<String, Object> convertPlainToNested(Map<String, Object> plain) { Map<String, Object> out = new HashMap<>(); for (Map.Entry<String, Object> entry : plain.entrySet()) { Map<String, Object> current = out; Object value = entry.getValue(); String[] parts = entry.getKey().split("\\."); List<String> strings = new ArrayList<>(Arrays.asList(parts)); while (!strings.isEmpty()) { String name = strings.remove(0); if (!current.containsKey(name)) { if (strings.isEmpty()) { current.put(name, value); break; }/*from w w w.ja va 2 s . co m*/ current.put(name, new HashMap<String, Object>()); } current = (Map<String, Object>) current.get(name); } } return out; }
From source file:com.clican.pluto.dataprocess.dpl.parser.bean.PrefixAndSuffix.java
public static void releaseLocalContext() { List<ProcessorContext> contextList = localContext.get(); contextList.remove(contextList.size() - 1); if (contextList.size() == 0) { localContext.remove();//from ww w . ja v a 2 s. c o m } }
From source file:ibeam.maven.plugins.Tools.java
/** * List recursively all folder of a given directory, excluding the current directory. * The result list is ordered on artifact last modification date. * /*from w w w . j a v a 2 s. c om*/ * @param file * @return a list of the folders and only folders (files are not listed) contained by the given directory, * the result is ordered on the modification date (ascending, with the most recent first). */ public static List<File> listSubFoldersOrdered(final File file) { List<File> result = new ArrayList<File>(); if (file.exists() && file.isDirectory()) { result = listFolders(file); result.remove(file); Collections.sort(result, new ArtifactFolderComparator()); } return result; }
From source file:Main.java
public static void removeListPrefItems(ListPreference listPref, String[] labels, String[] values, List<String> items) { List<String> labelsList = new ArrayList<String>(Arrays.asList(labels)); List<String> valuesList = new ArrayList<String>(Arrays.asList(values)); Iterator<String> it = valuesList.iterator(); while (it.hasNext()) { String value = it.next(); if (items.contains(value)) { labelsList.remove(valuesList.indexOf(value)); it.remove();/*from w ww . ja v a 2 s . co m*/ } } listPref.setEntries(labelsList.toArray(new String[1])); listPref.setEntryValues(valuesList.toArray(new String[1])); }
From source file:net.lldp.checksims.util.PairGenerator.java
/** * Generate all pairs for normal submissions, and pairs for archive submissions to compare to normal submissions. * * @param submissions Normal submissions - compared to each other and archive submissions * @param archiveSubmissions Archive submissions - only compared to normal submissions, not each other * @return Set of all unordered pairs required for comparison with archive directory *//* ww w .j ava 2s . c om*/ public static Set<Pair<Submission, Submission>> generatePairsWithArchive(Set<Submission> submissions, Set<Submission> archiveSubmissions) { checkNotNull(submissions); checkNotNull(archiveSubmissions); // TODO it may be desirable to allow comparison of a single submission to an archive // However, generatePairs fails if only 1 submission is given // (This would also require tweaks in the frontend) Set<Pair<Submission, Submission>> basePairs = generatePairs(submissions); // If we have no archive submissions, just return the same result generatePairs would if (archiveSubmissions.isEmpty()) { return basePairs; } // Now we need to add pairs for the archive submissions List<Submission> remaining = new ArrayList<>(); remaining.addAll(archiveSubmissions); // Loop through each archive submission while (!remaining.isEmpty()) { Submission first = remaining.get(0); remaining.remove(0); // For each archive submission, generate pairs for each normal submission for (Submission s : submissions) { Pair<Submission, Submission> pair = Pair.of(first, s); Pair<Submission, Submission> reversed = Pair.of(s, first); // Something's wrong, we've made a duplicate pair (but reversed) // Should never happen if (basePairs.contains(reversed)) { throw new RuntimeException("Internal error in pair generation: duplicate pair produced!"); } // One pair for each normal submission, consisting of the archive submission and the normal submission basePairs.add(pair); } } return basePairs; }
From source file:DeadlockDetectingLock.java
private static synchronized void freeIfHardwait(List l, Thread t) { if (l.contains(t)) l.remove(t); }
From source file:net.ontopia.topicmaps.utils.KeyGenerator.java
/** * PUBLIC: Makes a key for an association, but does not include * the player of the given role. The key is made up from the type * and for each role its type and player (except the given role for * which only the role type is included). This method is used to * create a signature for the association without taking one of the * roles into account./*from w w w . j av a 2 s .c o m*/ * @param assoc The association to make a key for * @param role The association role whose role player is to be left * out of the key. * @return string containing key * @since 3.4.2 */ public static String makeAssociationKey(AssociationIF assoc, AssociationRoleIF role) { StringBuilder sb = new StringBuilder(); // asssociation type key fragment sb.append(makeTypedKey(assoc)).append(SPACER).append(makeScopeKey(assoc)).append(SPACER); List<AssociationRoleIF> roles = new ArrayList<AssociationRoleIF>(assoc.getRoles()); roles.remove(role); String[] rolekeys = new String[roles.size()]; for (int i = 0; i < rolekeys.length; i++) rolekeys[i] = makeAssociationRoleKey(roles.get(i)); sb.append(makeTypedKey(role)).append(SPACER); Arrays.sort(rolekeys); sb.append(StringUtils.join(rolekeys, SPACER)); return sb.toString(); }
From source file:bwem.util.Utils.java
public static <T> void fastErase(final List<T> list, final int index) { // bwem_assert((0 <= i) && (i < (int)Vector.size())); if (!((0 <= index) && (index < list.size()))) { throw new IllegalArgumentException("index: " + index); }// w ww. j a v a2s . c om Collections.swap(list, index, list.size() - 1); list.remove(list.size() - 1); }