List of usage examples for com.google.common.collect Iterables elementsEqual
@CheckReturnValue public static boolean elementsEqual(Iterable<?> iterable1, Iterable<?> iterable2)
From source file:net.gageot.test.mocks.MockitoMatchers.java
@SuppressWarnings("unchecked") public static <T> List<T> eqIterable(final T... values) { return argThat(new ArgumentMatcher<List<T>>() { @Override/* ww w .j a v a 2 s .c o m*/ public boolean matches(Object argument) { return Iterables.elementsEqual((Iterable<T>) argument, ImmutableList.copyOf(values)); } }); }
From source file:org.apache.jackrabbit.oak.plugins.memory.AbstractPropertyState.java
/** * Checks whether the given two property states are equal. They are * considered equal if their names and types match, they have an equal * number of values, and each of the values is equal with the * corresponding value in the other property. * * @param a first property state/*from w w w.j ava 2s. c o m*/ * @param b second property state * @return {@code true} if the properties are equal, {@code false} otherwise */ public static boolean equal(PropertyState a, PropertyState b) { if (Objects.equal(a.getName(), b.getName()) && Objects.equal(a.getType(), b.getType())) { Type<?> type = a.getType(); if (a.isArray()) { return a.count() == b.count() && Iterables.elementsEqual((Iterable<?>) a.getValue(type), (Iterable<?>) b.getValue(type)); } else { return Objects.equal(a.getValue(type), b.getValue(type)); } } else { return false; } }
From source file:org.apache.hadoop.metrics2.impl.AbstractMetricsRecord.java
@Override public boolean equals(Object obj) { if (obj instanceof MetricsRecord) { final MetricsRecord other = (MetricsRecord) obj; return Objects.equal(timestamp(), other.timestamp()) && Objects.equal(name(), other.name()) && Objects.equal(description(), other.description()) && Objects.equal(tags(), other.tags()) && Iterables.elementsEqual(metrics(), other.metrics()); }/*from w ww . j a v a 2 s. c o m*/ return false; }
From source file:me.j360.dubbo.modules.util.collection.CollectionUtil.java
/** * ??.//from www .j a v a2 s . c om */ public static boolean elementsEqual(Iterable<?> iterable1, Iterable<?> iterable2) { return Iterables.elementsEqual(iterable1, iterable2); }
From source file:org.polarsys.reqcycle.traceability.cache.emfbased.predicates.TraceabilityLinkPredicate.java
@Override public boolean apply(TraceabilityLink arg0) { try {/*from w ww .j a v a 2 s .c o m*/ if (Objects.equal(arg0.getLabel(), label)) { if (Iterables.find(arg0.getSources(), Predicates.equalTo(source)) != null) { if (Iterables.elementsEqual(arg0.getTargets(), targets)) { return true; } } } } catch (NoSuchElementException e) { } return false; }
From source file:com.google.devtools.build.lib.actions.Actions.java
/** * Checks if the two actions are equivalent. This method exists to support sharing actions between * configured targets for cases where there is no canonical target that could own the action. In * the action graph construction this case shows up as two actions generating the same output * file.//from w w w . j a v a 2 s.c o m * * <p>This method implements an equivalence relationship across actions, based on the action * class, the key, and the list of inputs and outputs. */ public static boolean canBeShared(ActionAnalysisMetadata a, ActionAnalysisMetadata b) { if (!a.getMnemonic().equals(b.getMnemonic())) { return false; } // Non-Actions cannot be shared. if (!(a instanceof Action) || !(b instanceof Action)) { return false; } Action actionA = (Action) a; Action actionB = (Action) b; if (!actionA.getKey().equals(actionB.getKey())) { return false; } // Don't bother to check input and output counts first; the expected result for these tests is // to always be true (i.e., that this method returns true). if (!Iterables.elementsEqual(actionA.getMandatoryInputs(), actionB.getMandatoryInputs())) { return false; } if (!Iterables.elementsEqual(actionA.getOutputs(), actionB.getOutputs())) { return false; } return true; }
From source file:org.gradle.model.internal.manage.schema.cache.MultiWeakClassSet.java
@Override public boolean equals(Object obj) { if (obj instanceof MultiWeakClassSet) { MultiWeakClassSet other = Cast.uncheckedCast(obj); if (other.references.size() == references.size()) { return Iterables.elementsEqual(Iterables.transform(other.references, UNPACK_REF), Iterables.transform(references, UNPACK_REF)); }/*from www. j a v a2 s. co m*/ } return false; }
From source file:com.atlassian.jira.rest.client.api.domain.Operations.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }//from w ww . j av a2 s. c o m if (obj == null || getClass() != obj.getClass()) { return false; } final Operations other = (Operations) obj; return Iterables.elementsEqual(this.linkGroups, other.linkGroups); }
From source file:org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.java
public static Predicate<Firewall> equalsIpPermission(final IpPermission permission) { return new Predicate<Firewall>() { @Override//from ww w .j a v a 2 s.c om public boolean apply(Firewall input) { return Iterables.elementsEqual(permission.getGroupIds(), input.getSourceTags()) && Iterables.elementsEqual(permission.getCidrBlocks(), input.getSourceRanges()) && (input.getAllowed().size() == 1 && ruleEqualsIpPermission(permission) .apply(Iterables.getOnlyElement(input.getAllowed()))); } }; }
From source file:com.google.gxp.compiler.base.Constructor.java
public Constructor withParameters(List<Parameter> newParameters) { return Iterables.elementsEqual(parameters, newParameters) ? this : new Constructor(this, javaAnnotations, newParameters); }