Example usage for java.util Set equals

List of usage examples for java.util Set equals

Introduction

In this page you can find the example usage for java.util Set equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this set for equality.

Usage

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities.java

public static <T> boolean varListEqualUnordered(List<T> var, List<T> varArg) {
    Set<T> varSet = new HashSet<T>();
    Set<T> varArgSet = new HashSet<T>();
    varSet.addAll(var);
    varArgSet.addAll(varArg);/*from w  ww.  j a v a2  s  .  c om*/
    return varSet.equals(varArgSet);
}

From source file:com.opengamma.analytics.util.surface.StringValue.java

/**
 * Compare the values in two objects. The result is true if the list of strings are the same in both maps and the differences between the values associated of each of those strings are 
 * less than the tolerance.//from  ww w  .jav a  2  s. c o m
 * @param value1 The first "string value".
 * @param value2 The second "string value".
 * @param tolerance The tolerance.
 * @return The comparison flag.
 */
public static boolean compare(final StringValue value1, final StringValue value2, double tolerance) {
    Set<String> set1 = value1._data.keySet();
    Set<String> set2 = value2._data.keySet();
    if (!set1.equals(set2)) {
        return false;
    }
    for (final String p : set1) {
        if (Math.abs(value1._data.get(p) - value2._data.get(p)) > tolerance) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

/**
 * //from   www.  j a  v a2 s  .  co  m
 * 
 */
public static <T> boolean equalsAsSet(Collection<T> value1, Collection<T> value2) {
    Set<Object> s1 = new HashSet<Object>();
    for (Object v : value1) {
        s1.add(v);
    }
    Set<Object> s2 = new HashSet<Object>();
    for (Object v : value2) {
        s2.add(v);
    }
    return s1.equals(s2);
}

From source file:com.github.fge.jsonschema2avro.predicates.AvroPredicates.java

public static Predicate<AvroPayload> isEnum() {
    return new Predicate<AvroPayload>() {
        @Override/*w w w  . j ava2  s .c  o  m*/
        public boolean apply(final AvroPayload input) {
            final JsonNode node = schemaNode(input);
            final Set<String> set = Sets.newHashSet(node.fieldNames());
            set.retainAll(KNOWN_KEYWORDS);
            if (!set.equals(ImmutableSet.of("enum")))
                return false;

            // Test individual entries: they must be strings, and must be
            // the same "shape" as any Avro name
            for (final JsonNode element : node.get("enum")) {
                if (!element.isTextual())
                    return false;
                if (!isValidAvroName(element.textValue()))
                    return false;
            }

            return true;
        }
    };
}

From source file:com.github.fge.jsonschema2avro.predicates.AvroPredicates.java

public static Predicate<AvroPayload> simpleUnion() {
    return new Predicate<AvroPayload>() {
        @Override//from   w w w  .  j  av a 2 s . c om
        public boolean apply(final AvroPayload input) {
            // NOTE: enums within enums are forbidden. This is tested in
            // writers, not here.
            final JsonNode node = schemaNode(input);
            final Set<String> members = Sets.newHashSet(node.fieldNames());
            members.retainAll(KNOWN_KEYWORDS);
            return members.equals(ImmutableSet.of("anyOf")) || members.equals(ImmutableSet.of("oneOf"));
        }
    };
}

From source file:com.hueemulator.lighting.utils.TestUtils.java

/**
 * Tests the DOMs represented by two XML strings for equality by performing
 * a deep comparison.//from   w  ww  .  j av a  2  s  .  com
 *
 * @param xml1 represents the XML DOM to compare with xml2
 * @param xml2 represents the XML DOM to compare with xml1
 *
 * return true if the represented DOMs are equal, false otherwise
 */
public static boolean xmlsEqual(String xml1, String xml2) throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();

    Document doc1 = db.parse(new InputSource(new StringReader(xml1)));
    Document doc2 = db.parse(new InputSource(new StringReader(xml2)));

    Set<Object> childSet1 = getChildSet(doc1.getDocumentElement(), "");
    Set<Object> childSet2 = getChildSet(doc2.getDocumentElement(), "");

    return childSet1.equals(childSet2); // comparing sets does all the hard work :)
}

From source file:com.opengamma.analytics.util.surface.CubeValue.java

public static boolean compare(final CubeValue value1, final CubeValue value2, double tolerance) {
    Set<Triple<Double, Double, Double>> set1 = value1._data.keySet();
    Set<Triple<Double, Double, Double>> set2 = value2._data.keySet();
    if (!set1.equals(set2)) {
        return false;
    }/*from   w ww .ja  v a 2 s. c om*/
    for (final Triple<Double, Double, Double> p : set1) {
        if (Math.abs(value1._data.get(p) - value2._data.get(p)) > tolerance) {
            return false;
        }
    }
    return true;
}

From source file:com.opengamma.analytics.util.amount.CubeValue.java

public static boolean compare(final CubeValue value1, final CubeValue value2, final double tolerance) {
    final Set<Triple<Double, Double, Double>> set1 = value1._data.keySet();
    final Set<Triple<Double, Double, Double>> set2 = value2._data.keySet();
    if (!set1.equals(set2)) {
        return false;
    }//  w w w .  j a  v  a 2s  .c  o  m
    for (final Triple<Double, Double, Double> p : set1) {
        if (Math.abs(value1._data.get(p) - value2._data.get(p)) > tolerance) {
            return false;
        }
    }
    return true;
}

From source file:therian.operator.immutablecheck.DefaultImmutableChecker.java

private static void addImmutableTypeTo(final Set<Class<?>> target, final Class<?> type) {
    if (target.contains(type)) {
        return;//from   w  ww.j a v a2  s .  co  m
    }
    Class<?> c = type;
    while (c.isAnonymousClass()) {
        c = c.getEnclosingClass();
    }
    if (target.contains(c) && !target.equals(c)
            || StringUtils.startsWithAny(c.getSimpleName().toLowerCase(Locale.US), KNOWN_IMMUTABLE_PREFIXES)) {
        target.add(type);
    }
}

From source file:org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveJoinToMultiJoinRule.java

private static boolean isCombinablePredicate(JoinPredicateInfo joinPredInfo,
        JoinPredicateInfo leftChildJoinPredInfo, int noLeftChildInputs) throws CalciteSemanticException {
    Set<Integer> keys = joinPredInfo.getProjsJoinKeysInChildSchema(0);
    if (keys.isEmpty()) {
        return false;
    }/*from   www .  ja  va2  s.  c o m*/
    for (int i = 0; i < noLeftChildInputs; i++) {
        if (keys.equals(leftChildJoinPredInfo.getProjsJoinKeysInJoinSchema(i))) {
            return true;
        }
    }
    return false;
}