Example usage for org.apache.commons.collections CollectionUtils isEqualCollection

List of usage examples for org.apache.commons.collections CollectionUtils isEqualCollection

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils isEqualCollection.

Prototype

public static boolean isEqualCollection(final Collection a, final Collection b) 

Source Link

Document

Returns true iff the given Collection s contain exactly the same elements with exactly the same cardinalities.

Usage

From source file:com.xebia.aphillips.easymock.CollectionEqualsMatcherDemo.java

@Test
public void usingCapture() {
    StubTarget mock = createMock(StubTarget.class);
    String arg = "007";
    Capture<Collection<String>> argsCapture = new Capture<Collection<String>>();
    mock.method(capture(argsCapture));//  www  .j  a  v a  2  s .com
    expectLastCall();
    replay(mock);

    Set<String> args = new HashSet<String>();
    args.add(arg);
    mock.method(args);

    verify(mock);
    assertTrue("Expected equal collections",
            CollectionUtils.isEqualCollection(Arrays.asList(arg), argsCapture.getValue()));
}

From source file:com.qrmedia.commons.collections.PairUtilsTest.java

@SuppressWarnings("unchecked")
@Test//from   www. j  av  a 2  s .com
public void toPairs() {
    String firstObject1 = "007";
    String firstObject2 = "008";
    Object secondObject = new Object();

    assertTrue(CollectionUtils.isEqualCollection(
            Arrays.asList(new Pair<String, Object>(firstObject1, secondObject),
                    new Pair<String, Object>(firstObject2, secondObject)),
            PairUtils.toPairs(Arrays.asList(firstObject1, firstObject2), secondObject)));
}

From source file:com.qrmedia.commons.lang.ClassUtilsTest.java

@Test
public void getAllDeclaredFields() {
    List<Field> expectedFields = new ArrayList<Field>();
    expectedFields.addAll(Arrays.asList(Parent.class.getDeclaredFields()));
    expectedFields.addAll(Arrays.asList(Child.class.getDeclaredFields()));

    assertTrue(CollectionUtils.isEqualCollection(expectedFields, ClassUtils.getAllDeclaredFields(Child.class)));
}

From source file:net.sourceforge.fenixedu.domain.accessControl.academicAdministration.EnumArray.java

@Override
public boolean equals(Object obj) {
    if (obj instanceof EnumArray) {
        return CollectionUtils.isEqualCollection(elements, ((EnumArray<T>) obj).elements);
    }/*  w  w  w .  ja  v  a2 s.com*/
    return false;
}

From source file:com.github.DataLoaderTest.java

public void testLoadPredictings() throws IOException {
    final Watcher w1 = new Watcher("1");
    final Watcher w2 = new Watcher("5");

    final Set<Watcher> expected = new HashSet<Watcher>(Arrays.asList(w1, w2));

    assertTrue(CollectionUtils.isEqualCollection(expected, DataLoader.loadPredictings()));
}

From source file:com.jbuncle.mysqlsynchroniser.structure.objects.Table.java

@Override
public boolean equals(Object obj) {
    if (!(obj instanceof Table)) {
        return false;
    }//from   w w w.  ja  v a  2 s  .  c  o m
    final Table other = (Table) obj;
    if (!Objects.equals(this.tableName, other.tableName)) {
        return false;
    }
    if (!CollectionUtils.isEqualCollection(this.columns, other.columns)) {
        return false;
    }
    return CollectionUtils.isEqualCollection(this.indexes, other.indexes);
}

From source file:hudson.matrix.AxisList.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }/* w ww.ja  v  a2s . c om*/
    if (o == null || getClass() != o.getClass()) {
        return false;
    }
    if (!super.equals(o)) {
        return false;
    }
    AxisList axisList = (AxisList) o;

    return CollectionUtils.isEqualCollection(this, axisList);
}

From source file:com.thoughtworks.go.plugin.access.configrepo.contract.material.CRFilter.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }//  w w w . ja  va 2  s  . c o  m

    CRFilter that = (CRFilter) o;
    if (that == null)
        return false;

    if (ignore != null ? !CollectionUtils.isEqualCollection(this.ignore, that.ignore) : that.ignore != null) {
        return false;
    }
    if (whitelist != null ? !CollectionUtils.isEqualCollection(this.whitelist, that.whitelist)
            : that.whitelist != null) {
        return false;
    }

    return true;
}

From source file:com.omnigon.aem.common.utils.JcrPropertyUtil.java

/**
 *
 * @param node JCR node/* w w  w .ja  v  a2 s  .co  m*/
 * @param newTags -
 * @throws RepositoryException -
 */
public static void updateTagsProperty(final Node node, List<Tag> newTags) throws RepositoryException {
    List<String> tags = new ArrayList<String>(newTags.size());

    for (Tag tag : newTags) {
        tags.add(tag.getTagID());
    }

    if (node.hasProperty(TagConstants.PN_TAGS)) {
        Value[] values = node.getProperty(TagConstants.PN_TAGS).getValues();
        if (values != null) {
            List<String> existingTags = new ArrayList<String>(values.length);

            for (Value value : values) {
                existingTags.add(value.getString());
            }

            if (!CollectionUtils.isEqualCollection(existingTags, tags)) {
                updateTagProperty(node, tags);
            }
        } else {
            updateTagProperty(node, tags);
        }
    } else {
        updateTagProperty(node, tags);
    }
}

From source file:com.jbuncle.mysqlsynchroniser.structure.objects.Index.java

public boolean equals(Index target) {
    if (isPrimaryKey() ^ target.isPrimaryKey()) {
        return false;
    } else if (isUniqueKey() ^ target.isUniqueKey()) {
        return false;
    } else if (!CollectionUtils.isEqualCollection(this.columnNames, target.columnNames)) {
        return false;
    }//from  w w  w .  java 2 s. c  o m
    return true;
}