List of usage examples for com.google.common.collect Iterables removeAll
public static boolean removeAll(Iterable<?> removeFrom, Collection<?> elementsToRemove)
From source file:org.asoem.greyfish.utils.collect.AbstractFunctionalList.java
@Override public List<E> remove(final Predicate<? super E> predicate) { final ImmutableList<E> remove = ImmutableList.copyOf(filter(predicate)); Iterables.removeAll(this, remove); return remove; }
From source file:com.github.wnameless.math.NumberSystemConverter.java
/** * Creates a number system converter.//from w w w . j a va2 s. c o m * * @param base1 * a List of each digit character in base 1, the 0-based order of * each digit is corresponding to its decimal value * @param base2 * a List of each digit character in base 2, the 0-based order of * each digit is corresponding to its decimal value */ public NumberSystemConverter(List<Character> base1, List<Character> base2) { checkNotNull(base1); checkNotNull(base2); checkArgument(base1.size() >= 2 && base2.size() >= 2, "All bases must include more than 2 digits."); checkArgument(!base1.contains(null) && !base2.contains(null), "All bases must NOT include null."); Set<Character> set1 = newLinkedHashSet(base1); Set<Character> set2 = newLinkedHashSet(base2); checkArgument(base1.size() == set1.size() && base2.size() == set2.size(), "All digits of a base must be unique."); List<Character> invalidChars = ImmutableList.of(' ', '-'); checkArgument(!Iterables.removeAll(set1, invalidChars) && !Iterables.removeAll(set2, invalidChars), "All digits of a base must NOT include whitespace ' ' or minus sign '-'."); this.base1 = ImmutableList.copyOf(base1); this.base2 = ImmutableList.copyOf(base2); }
From source file:com.cognifide.aet.job.common.comparators.accessibility.report.AccessibilityReportGenerator.java
private int filterAndCount(boolean filter, IssueType type) { int result = 0; Iterable<AccessibilityIssue> issues = Iterables.filter(nonExcludedIssues, new IssueTypePredicate(type)); if (filter) { Iterables.removeAll(nonExcludedIssues, Lists.newArrayList(issues)); Iterable<AccessibilityIssue> excluded = Iterables.filter(excludedIssues, new IssueTypePredicate(type)); Iterables.removeAll(excludedIssues, Lists.newArrayList(excluded)); } else {// w w w . j a v a 2s . c o m result = Iterables.size(issues); } return result; }
From source file:com.github.wnameless.math.NumberSystemConverter.java
private void checkNoInvalidDigit(String base1Digits) { List<Character> inputChars = newArrayList(Chars.asList(base1Digits.toCharArray())); Iterables.removeAll(inputChars, base1); checkArgument(inputChars.size() == 0, "Input contains invalid digit."); }
From source file:org.eclipse.sirius.ui.tools.internal.actions.analysis.RemoveSemanticResourceAction.java
private boolean checkResources() { boolean okForRemove = true; if (session instanceof DAnalysisSessionEObject) { // Controlled resource should be removed with uncontrol command okForRemove = !Iterables.removeAll(toRemove, ((DAnalysisSessionEObject) session).getControlledResources()); }/* w ww.ja va2 s. c om*/ if (okForRemove) { for (final DRepresentation representation : DialectManager.INSTANCE.getAllRepresentations(session)) { if (representation instanceof DSemanticDecorator) { final DSemanticDecorator decorator = (DSemanticDecorator) representation; if (decorator.getTarget() != null && this.toRemove.contains(decorator.getTarget().eResource())) { okForRemove = false; break; } } } } return okForRemove; }
From source file:org.obeonetwork.graal.design.services.actor.ActorUtils.java
/** * Get the list of actors that should be visually connected to a task * The list depends on inherited actors and already visible tasks on diagram * @param task The task for which we want the actors list * @param tasksOnDiagram List of visible tasks on diagram * @return List of Actors/* w w w. ja v a 2 s .co m*/ */ private Collection<Actor> getVisibleLinksToActorsFromTask(Task task, final List<Task> tasksOnDiagram) { if (task.getActors().isEmpty()) { // Get using tasks that are displayed on diagram List<Task> usingTasksOnDiagram = Lists.newArrayList(task.getUsedBy()); Iterables.retainAll(usingTasksOnDiagram, tasksOnDiagram); // Filter the related actors to keep those not already associated with a displayed using task List<Actor> relatedActors = Lists.newArrayList(task.getRelatedActors()); for (Task usingTask : usingTasksOnDiagram) { if (!relatedActors.isEmpty()) { Iterables.removeAll(relatedActors, usingTask.getRelatedActors()); } else { break; } } // If some of the actors are not linked to displayed tasks // we then have to display the whole actors list to prevent from misunderstanding if (!relatedActors.isEmpty()) { return task.getRelatedActors(); } else { return Collections.emptyList(); } } else { return task.getActors(); } }
From source file:org.eclipse.sirius.ui.tools.internal.dialogs.SemanticResourceDialog.java
@Override protected boolean processResources() { final List<URI> representationFiles = Lists.newArrayList(); final List<URI> urIs = getURIs(); for (URI uri : urIs) { if (new FileQuery(uri.fileExtension()).isSessionResourceFile()) { representationFiles.add(uri); }/*from w w w . j a v a2 s . co m*/ } if (!representationFiles.isEmpty()) { Status status = new Status(IStatus.WARNING, SiriusEditPlugin.ID, MessageFormat.format( Messages.SemanticResourceDialog_representationFilesCantBeAdded_status, representationFiles)); ErrorDialog.openError(getParentShell(), Messages.SemanticResourceDialog_representationFilesCantBeAdded_title, Messages.SemanticResourceDialog_representationFilesCantBeAdded_message, status); Iterables.removeAll(urIs, representationFiles); if (uriField != null && !uriField.isDisposed() && !urIs.isEmpty()) { StringBuilder sb = new StringBuilder(); for (URI uri : urIs) { sb.append(uri); sb.append(SemanticResourceDialog.SEPARATOR); } uriField.setText(sb.toString().trim()); } return false; } return true; }
From source file:org.eclipse.sirius.diagram.ui.business.internal.edit.helpers.EdgeReconnectionHelper.java
/** * Recovers the resulting edge of a reconnection operation. * /*from www . j av a2 s. c o m*/ * @return the resulting edge of a reconnection operation. */ public Edge getReconnectedEdge() { Edge edge = null; if (reconnectionKind == ReconnectionKind.RECONNECT_SOURCE_LITERAL) { final List<Edge> sourceEdges = new ArrayList<Edge>(reconnectionTarget.getSourceEdges()); Iterables.removeAll(sourceEdges, reconnectionTargetEdges); Predicate<Edge> notToReconnectingEdge = new Predicate<Edge>() { @Override public boolean apply(Edge input) { return !sourceEdges.contains(input.getTarget()); } }; // For case with reconnect edge source from borderedNode to // borderedNode // when borderedNode is mapping with EReference if (sourceEdges.isEmpty() && reconnectionTarget.getElement() instanceof AbstractDNode) { AbstractDNode abstractDNode = (AbstractDNode) reconnectionTarget.getElement(); List<DNode> borderedNodes = abstractDNode.getOwnedBorderedNodes(); if (!borderedNodes.isEmpty()) { DNode borderedNode = borderedNodes.get(borderedNodes.size() - 1); Collection<EObject> inverseReferences = new EObjectQuery(borderedNode) .getInverseReferences(NotationPackage.eINSTANCE.getView_Element()); Node nodeSource = Iterables.getOnlyElement(Iterables.filter(inverseReferences, Node.class)); List<Edge> sourceEdgesOfBorderedNode = new ArrayList<Edge>(nodeSource.getSourceEdges()); edge = Iterables .getOnlyElement(Iterables.filter(sourceEdgesOfBorderedNode, notToReconnectingEdge)); } } else { edge = Iterables.getOnlyElement(Iterables.filter(sourceEdges, notToReconnectingEdge)); } } else { final List<Edge> targetEdges = new ArrayList<Edge>(reconnectionTarget.getTargetEdges()); Iterables.removeAll(targetEdges, reconnectionTargetEdges); Predicate<Edge> notFromReconnectingEdge = new Predicate<Edge>() { @Override public boolean apply(Edge input) { return !targetEdges.contains(input.getSource()); } }; // For case with reconnect edge target from borderedNode to // borderedNode // when borderedNode is mapping with EReference if (targetEdges.isEmpty() && reconnectionTarget.getElement() instanceof AbstractDNode) { AbstractDNode abstractDNode = (AbstractDNode) reconnectionTarget.getElement(); List<DNode> borderedNodes = abstractDNode.getOwnedBorderedNodes(); if (!borderedNodes.isEmpty()) { DNode borderedNode = borderedNodes.get(borderedNodes.size() - 1); Collection<EObject> inverseReferences = new EObjectQuery(borderedNode) .getInverseReferences(NotationPackage.eINSTANCE.getView_Element()); Node nodeTarget = Iterables.getOnlyElement(Iterables.filter(inverseReferences, Node.class)); List<Edge> targetEdgesOfBorderedNode = new ArrayList<Edge>(nodeTarget.getTargetEdges()); edge = Iterables .getOnlyElement(Iterables.filter(targetEdgesOfBorderedNode, notFromReconnectingEdge)); } } else { edge = Iterables.getOnlyElement(Iterables.filter(targetEdges, notFromReconnectingEdge)); } } return edge; }
From source file:com.netxforge.netxstudio.server.logic.monitoring.RFSServiceMonitoringLogic.java
/** * Initialize a new Monitor, clean monitors which match the same period. * Overlapping periods are also discarded. * /*from w w w . j a va 2 s . c o m*/ * @param dtr */ public void initServiceMonitor(DateTimeRange dtr) { serviceMonitor = ServicesFactory.eINSTANCE.createServiceMonitor(); // what name should a servicemonitor have? serviceMonitor.setName(rfsService.getServiceName()); serviceMonitor.setPeriod(dtr); // The revision will hold the Object ID and creation time. serviceMonitor.setRevision(NonModelUtils.dateAndTime(NonModelUtils.todayAndNow())); // Do the ONFE thing, disable for now as we catch ONFEs in own policy. // this.getModelUtils().findAndCleanONFE(rfsService, // ServicesPackage.Literals.SERVICE__SERVICE_MONITORS); rfsService.getServiceMonitors().add(0, serviceMonitor); // Add at // beginning. List<ServiceMonitor> serviceMonitorDuplicates = StudioUtils.serviceMonitorDuplicates(rfsService, dtr); if (LogicActivator.DEBUG) { LogicActivator.TRACE.trace(LogicActivator.TRACE_LOGIC_OPTION, "Creating Service Monitor for period" + StudioUtils.periodToString(dtr)); if (serviceMonitorDuplicates.size() > 0) { LogicActivator.TRACE.trace(LogicActivator.TRACE_LOGIC_OPTION, "Removing " + serviceMonitorDuplicates.size() + " entries for the same period"); } } // remove them with Iterables.removeAll(rfsService.getServiceMonitors(), serviceMonitorDuplicates); getEngine().setServiceMonitor(serviceMonitor); }
From source file:org.apache.hadoop.hive.ql.metadata.VirtualColumn.java
public static Collection<String> removeVirtualColumns(final Collection<String> columns) { Iterables.removeAll(columns, VIRTUAL_COLUMN_NAMES); return columns; }