List of usage examples for com.google.common.collect Iterables elementsEqual
@CheckReturnValue public static boolean elementsEqual(Iterable<?> iterable1, Iterable<?> iterable2)
From source file:org.eclipse.sirius.tools.api.interpreter.InterpreterRegistry.java
/** * Prepare all imports of the specified model request interpreter and * session.//from w w w. j a v a 2s . c o m * * @param inter * the model requests interpreter to prepare. * @param session * the current session * @since 0.9.0 */ public static void prepareImportsFromSession(final IInterpreter inter, final Session session) { Collection<String> imports = inter.getImports(); final LinkedHashSet<String> allImports = new LinkedHashSet<String>(); if (session != null) { for (final Viewpoint vp : session.getSelectedViewpoints(false)) { if (vp.eResource() != null) { for (JavaExtension javaExtension : vp.getOwnedJavaExtensions()) { allImports.add(javaExtension.getQualifiedClassName()); } } } } if (allImports.size() != imports.size() || !Iterables.elementsEqual(allImports, imports)) { inter.clearImports(); for (String dependency : allImports) { inter.addImport(dependency); } } }
From source file:org.eclipse.sirius.diagram.business.internal.metamodel.helper.DiagramElementMappingHelper.java
/** * Evaluate the semantic elements feature of the mapping and affect them to * the given diagram element./* w w w . jav a2 s . c o m*/ * * Add the semantic target if there is no computed elements, except the case * of non domain based edges. * * The semantic target of the current DDiagramElement must be set. * * @param self * the current DiagramElementMapping * @param dde * the current created DDiagramElement. * @param interpreter * the current interpreter. */ public static void refreshSemanticElements(DiagramElementMapping self, DDiagramElement dde, final IInterpreter interpreter) { Collection<EObject> semanticElements = Lists.newArrayList(); if (!StringUtil.isEmpty(self.getSemanticElements())) { semanticElements = DiagramElementMappingHelper.evaluateSemanticElements(self, dde, interpreter); } if ((semanticElements == null || semanticElements.isEmpty()) && dde.getTarget() != null) { // Do not add the semantic target for relation based edges. if (!(self instanceof EdgeMapping) || ((EdgeMapping) self).isUseDomainElement()) { semanticElements = Collections.singletonList(dde.getTarget()); } } if (!semanticElements.isEmpty() && !Iterables.elementsEqual(semanticElements, dde.getSemanticElements())) { dde.getSemanticElements().clear(); dde.getSemanticElements().addAll(semanticElements); } }
From source file:com.atlassian.jira.rest.client.api.domain.OperationGroup.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/*from w w w. j av a 2s .c o m*/ if (obj == null || getClass() != obj.getClass()) { return false; } final OperationGroup other = (OperationGroup) obj; return Objects.equal(this.id, other.id) && Objects.equal(this.header, other.header) && Iterables.elementsEqual(this.links, other.links) && Iterables.elementsEqual(this.groups, other.groups) && Objects.equal(this.weight, other.weight); }
From source file:org.apache.abdera2.activities.extra.Difference.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Difference other = (Difference) obj; if (added == null) { if (other.added != null) return false; } else if (!Iterables.elementsEqual(added, other.added)) return false; if (changed == null) { if (other.changed != null) return false; } else if (!Iterables.elementsEqual(changed, other.changed)) return false; if (removed == null) { if (other.removed != null) return false; } else if (!Iterables.elementsEqual(removed, other.removed)) return false; return true;/* w w w .j a v a 2 s. c om*/ }
From source file:info.magnolia.ui.admincentral.shellapp.pulse.message.MessagesContainer.java
@Override public void filterByItemCategory(PulseItemCategory category) { MessageType[] newVisibleTypes;// w ww .j a v a2s. c o m switch (category) { case PROBLEM: newVisibleTypes = new MessageType[] { MessageType.ERROR, MessageType.WARNING }; break; case INFO: newVisibleTypes = new MessageType[] { MessageType.INFO }; break; default: newVisibleTypes = MessageType.values(); } List<MessageType> newVisibleTypeList = Arrays.asList(newVisibleTypes); if (!Iterables.elementsEqual(newVisibleTypeList, getQueryDefinition().types())) { getQueryDefinition().setTypes(newVisibleTypeList); refresh(); } }
From source file:com.ning.arecibo.dashboard.resources.GroupsAndSampleKindsStore.java
void updateCacheIfNeeded(final Iterable<CategoryAndSampleKindsForHosts> newSampleKinds) { if (collectorSampleKinds == null || !Iterables.elementsEqual(newSampleKinds, collectorSampleKinds)) { log.info("Detected change in sample kinds - updating cache"); cacheGroupsAndSampleKinds(newSampleKinds); }// w ww .j a v a 2s . c o m }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.ordering.RefreshOrderingHelper.java
/** * Determines if two lists have the same contents in the same order or not. * Elements are compared using {@link #equals(Object)}. * //from w w w. j a v a 2 s . c om * @param <T> * the type of elements in the lists. * @param oldValue * the old list of values. * @param newValue * the new lists of values. * @return <code>true</code> if the list of new values have different * contents or the same elements but in a different order rom the * old one. */ public static <T> boolean differentContents(List<T> oldValue, List<T> newValue) { if (oldValue.size() != newValue.size()) { return true; } else { return !Iterables.elementsEqual(oldValue, newValue); } }
From source file:org.metaborg.intellij.configuration.MetaborgApplicationConfigState.java
/** * Determines whether this instance and the specified instance are equal. * * @param other The other instance.// w w w. jav a2 s . c o m * @return <code>true</code> when the instances are equal; * otherwise, <code>false</code>. */ public boolean equals(@Nullable final MetaborgApplicationConfigState other) { if (other == this) return true; if (other == null) return false; // Compare the fields here. return Iterables.elementsEqual(this.loadedLanguages, other.loadedLanguages); }
From source file:info.magnolia.ui.admincentral.shellapp.pulse.task.TasksContainer.java
@Override public void filterByItemCategory(PulseItemCategory category) { Task.Status[] statuses;//from w w w . j a v a2 s.c om switch (category) { case UNCLAIMED: statuses = new Task.Status[] { Task.Status.Created }; break; case ONGOING: statuses = new Task.Status[] { Task.Status.InProgress }; break; case DONE: statuses = new Task.Status[] { Task.Status.Resolved }; break; case FAILED: statuses = new Task.Status[] { Task.Status.Failed }; break; case SCHEDULED: statuses = new Task.Status[] { Task.Status.Scheduled }; break; default: statuses = Task.Status.values(); } List<Task.Status> newStatuses = Arrays.asList(statuses); if (!Iterables.elementsEqual(newStatuses, getQueryDefinition().types())) { getQueryDefinition().setTypes(newStatuses); refresh(); } }
From source file:be.nbb.xdb.DbRawDataUtil.java
@Nonnull public static <C> boolean isSortRequired(boolean distinct, @Nonnull List<C> selectColumns, @Nonnull List<C> orderColumns) { return !orderColumns.isEmpty() && !(distinct && Iterables.elementsEqual(selectColumns, orderColumns)); }