List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:biz.netcentric.cq.tools.actool.configuration.CqActionsMapping.java
/** * method that converts jcr:privileges to cq actions * // w ww . j a v a2s .c om * @param jcrPrivilegesString * comma separated String containing jcr:privileges * @return comma separated String containing the assigned cq actions * @throws RepositoryException * @throws AccessControlException */ public static String getCqActions(final String jcrPrivilegesString, AccessControlManager aclManager) throws AccessControlException, RepositoryException { List<String> jcrPrivileges = new ArrayList<String>(Arrays.asList(jcrPrivilegesString.split(","))); // go through all aggregates to extend the list with all non-aggregate privileges for (String jcrPrivilege : jcrPrivilegesString.split(",")) { Privilege privilege = aclManager.privilegeFromName(jcrPrivilege); for (Privilege aggregatedPrivileges : privilege.getAggregatePrivileges()) { jcrPrivileges.add(aggregatedPrivileges.getName()); } } // loop through keySet of cqActions. Remove successively all privileges // which are associated to a cq action from jcrPrivileges string // and add this actions name to actions string Set<String> cqActions = ACTIONS_MAP.keySet(); String actionsString = ""; for (String action : cqActions) { List<String> jcrPrivilegesFromMap = ACTIONS_MAP.get(action); if (jcrPrivileges.containsAll(jcrPrivilegesFromMap)) { jcrPrivileges.removeAll(jcrPrivilegesFromMap); actionsString = actionsString + action + ","; } } // remove last comma from actions string actionsString = StringUtils.chop(actionsString); if (actionsString.isEmpty()) { actionsString = ""; } return actionsString; }
From source file:com.hp.autonomy.frontend.find.core.fields.FieldsController.java
@RequestMapping(value = GET_PARAMETRIC_FIELDS_PATH, method = RequestMethod.GET) @ResponseBody//from w w w . j a v a 2 s . co m public List<TagName> getParametricFields(final R request) throws E { final Map<FieldTypeParam, List<TagName>> response = fieldsService.getFields(request, FieldTypeParam.Parametric, FieldTypeParam.Numeric, FieldTypeParam.NumericDate); final List<TagName> parametricFields = new ArrayList<>(response.get(FieldTypeParam.Parametric)); parametricFields.removeAll(response.get(FieldTypeParam.Numeric)); parametricFields.removeAll(response.get(FieldTypeParam.NumericDate)); return parametricFields; }
From source file:com.epam.catgenome.manager.vcf.VcfFileManager.java
@Transactional(propagation = Propagation.REQUIRED) public List<VcfFile> loadVcfFiles(List<Long> ids) { if (CollectionUtils.isEmpty(ids)) { return Collections.emptyList(); }//from ww w. ja va2s . c o m List<VcfFile> files = vcfFileDao.loadVcfFiles(ids); if (files.size() != ids.size()) { List<Long> notFound = new ArrayList<>(ids); notFound.removeAll(files.stream().map(BaseEntity::getId).collect(Collectors.toList())); Assert.isTrue(notFound.isEmpty(), MessageHelper.getMessage(MessagesConstants.ERROR_FILE_NOT_FOUND, notFound.stream().map(i -> i.toString()).collect(Collectors.joining(", ")))); } return files; }
From source file:com.google.mr4c.sources.FileSourceTester.java
public void testFileList(FileSource src) throws IOException { // get extra files that we aren't going to add anyway List<String> start = src.getAllFileNames(); start.removeAll(m_files); addAllTestData(src);//from w w w . jav a 2 s .c o m List<String> files = new ArrayList<String>(src.getAllFileNames()); files.removeAll(start); Collections.sort(files); assertEquals(m_files, files); }
From source file:com.netflix.spinnaker.orca.kato.pipeline.ParallelDeployClusterExtractor.java
@Override public void updateStageClusters(Map stage, List<Map> replacements) { List<Map> clusters = (List<Map>) stage.get("clusters"); stage.put("clusters", new ArrayList<>(replacements.subList(0, clusters.size()))); replacements.removeAll((List<Map>) stage.get("clusters")); }
From source file:com.flexive.tests.embedded.SequencerTest.java
@Test public void customSequencer() throws Exception { List<CustomSequencer> startList = id.getCustomSequencers(); String seq1 = "A" + RandomStringUtils.randomAlphanumeric(16).toUpperCase(); String seq2 = "B" + RandomStringUtils.randomAlphanumeric(16).toUpperCase(); String seq3 = "C" + RandomStringUtils.randomAlphanumeric(16).toUpperCase(); id.createSequencer(seq1, true, 0);//from w w w. ja v a 2s . com id.createSequencer(seq2, true, id.getMaxId()); id.createSequencer(seq3, false, id.getMaxId()); Assert.assertTrue(id.sequencerExists(seq1), "Expected sequencer " + seq1 + " to exist!"); Assert.assertTrue(id.sequencerExists(seq2), "Expected sequencer " + seq2 + " to exist!"); Assert.assertTrue(id.sequencerExists(seq3), "Expected sequencer " + seq3 + " to exist!"); Assert.assertTrue(id.getCustomSequencerNames().contains(seq1)); Assert.assertTrue(id.getCustomSequencerNames().contains(seq2)); Assert.assertTrue(id.getCustomSequencerNames().contains(seq3)); long i1 = id.getId(seq1); Assert.assertEquals(i1, 1); long i2 = id.getId(seq1); Assert.assertTrue(i2 > i1, "Expected a higher id after 2nd getId()!"); i1 = id.getId(seq2); //call should cause the sequencer to roll over Assert.assertEquals(i1, 0, "Expected: " + 0 + ", got: " + i1); i1 = id.getId(seq2); //should be 1 after rollover Assert.assertEquals(i1, 1, "Expected: " + 1 + ", got: " + i1); Assert.assertTrue(i1 <= id.getCurrentId(seq2), "Expected " + i1 + " of " + seq2 + " to be <= " + id.getCurrentId(seq2)); try { id.getId(seq3); Assert.fail("Expected an exception since seq3 should be exhausted!"); } catch (FxApplicationException e) { //expected } List<CustomSequencer> g2 = id.getCustomSequencers(); g2.removeAll(startList); Assert.assertTrue(g2.size() == 3, "Expected a size of 3, but got " + g2.size()); Assert.assertTrue(g2.get(0).getName().equals(seq1), "Expected " + seq1 + " got " + g2.get(0).getName()); Assert.assertTrue(g2.get(1).getName().equals(seq2), "Expected " + seq2 + " got " + g2.get(1).getName()); Assert.assertTrue(g2.get(2).getName().equals(seq3), "Expected " + seq3 + " got " + g2.get(2).getName()); Assert.assertTrue(g2.get(0).isAllowRollover()); Assert.assertTrue(g2.get(1).isAllowRollover()); Assert.assertFalse(g2.get(2).isAllowRollover()); id.removeSequencer(seq1); id.removeSequencer(seq2); id.removeSequencer(seq3); Assert.assertTrue(id.getCustomSequencers().size() == startList.size()); Assert.assertFalse(id.getCustomSequencerNames().contains(seq1)); Assert.assertFalse(id.getCustomSequencerNames().contains(seq2)); Assert.assertFalse(id.getCustomSequencerNames().contains(seq3)); }
From source file:de.tud.inf.db.sparqlytics.model.Measure.java
/** * Creates a new measure with the given name, seed pattern, numeric * expression and aggregation function./*from w w w . ja va 2 s . c o m*/ * * @param name the name of the measure * @param seedPattern the seed pattern connecting the numeric * expression with the facts * @param expression the expression to derive numeric values from * the facts * @param aggregationFunction the aggregation function to apply to the * numeric values * * @throws NullPointerException if any argument is {@code null} * @throws IllegalArgumentException if the numeric expression references a * variable not present in the seed pattern * or if the aggregation function is * unsupported */ public Measure(final String name, final Element seedPattern, final Expr expression, final String aggregationFunction) { super(name); if (expression == null || aggregationFunction == null) { throw new NullPointerException(); } else { this.aggregationFunction = aggregationFunction.toUpperCase(); int index = Arrays.binarySearch(AGGREGATION_FUNCTIONS, this.aggregationFunction); if (index < 0) { throw new IllegalArgumentException("Unsupported aggregation function: " + aggregationFunction); } } List<Var> vars = new LinkedList<>(); ExprVars.varsMentioned(vars, expression); vars.removeAll(PatternVars.vars(seedPattern)); if (!vars.isEmpty()) { throw new IllegalArgumentException( "Expression references unknown variable(s): " + StringUtils.join(vars, ", ")); } this.seedPattern = seedPattern; this.expression = expression; }
From source file:de.tud.inf.db.sparqlytics.model.Dimension.java
/** * Creates a new dimension with the given name, seed pattern and levels. * The special level {@link Level#ALL} is automatically appended to the * provided levels./*from w w w.j a v a 2s. com*/ * * @param name the name of the dimension * @param seedPattern the seed pattern connecting the level expression * with the facts * @param levels the levels * * @throws NullPointerException if any argument is {@code null} * @throws IllegalArgumentException if a level expressions references a * variable not present in the seed pattern * or if no levels were provided */ public Dimension(final String name, final Element seedPattern, final List<Level> levels) { super(name); if (levels.isEmpty()) { throw new IllegalArgumentException(); } Collection<Var> seedPatternVars = PatternVars.vars(seedPattern); for (Level level : levels) { List<Var> vars = new LinkedList<>(); ExprVars.varsMentioned(vars, level.getExpression()); vars.removeAll(seedPatternVars); if (!vars.isEmpty()) { throw new IllegalArgumentException("Level \"" + level.getName() + "\" references unknown variable(s): " + StringUtils.join(vars, ", ")); } } this.seedPattern = seedPattern; this.levels = new ArrayList<>(levels.size() + 1); this.levels.addAll(levels); this.levels.add(Level.ALL); }
From source file:co.mcme.barry.listeners.ChatListener.java
@EventHandler(priority = EventPriority.MONITOR) public void onMathChat(AsyncPlayerChatEvent event) { if (event.getMessage().contains(".math")) { Player p = event.getPlayer();/* w w w.j a va 2s .c o m*/ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); String[] msg = event.getMessage().split(" "); if (msg.length > 1) { try { List<String> list = new ArrayList<>(Arrays.asList(msg)); list.removeAll(Arrays.asList("", null, ".math")); String expression = StringUtils.join(list, " "); BarryPlugin.sendGlobalMessage("(" + ChatColor.DARK_AQUA + p.getName() + ChatColor.WHITE + ") " + expression + " = " + engine.eval(expression)); } catch (ScriptException ex) { b.sendTargetedMessage("I can't figure out that math problem.", p); } } else { b.sendTargetedMessage("I need to know what math to do", p); } } }
From source file:org.jasig.portlet.contacts.context.impl.ContactContextImpl.java
public boolean provides(Collection<String> keys) { log.debug(toString());/*from ww w . ja v a 2 s. c om*/ List<String> keyList = new ArrayList<String>(); keyList.addAll(keys); for (ContextProvider provider : contextProviders) { keyList.removeAll(provider.keySet()); } return keyList.isEmpty(); }