Tabnine Logo
org.apache.commons.collections.collection
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.commons.collections.collection

Best Java code snippets using org.apache.commons.collections.collection (Showing top 20 results out of 6,741)

origin: commons-collections/commons-collections

/**
 * Create a Composite Collection with only coll composited.
 * 
 * @param coll  a collection to decorate
 */
public CompositeCollection(Collection coll) {
  this();
  this.addComposited(coll);
}

origin: commons-collections/commons-collections

/**
 * Factory method to create an unmodifiable bounded collection.
 * 
 * @param coll  the <code>BoundedCollection</code> to decorate, must not be null
 * @return a new unmodifiable bounded collection
 * @throws IllegalArgumentException if bag is null
 */
public static BoundedCollection decorate(BoundedCollection coll) {
  return new UnmodifiableBoundedCollection(coll);
}

origin: commons-collections/commons-collections

/**
 * Factory method to create a synchronized collection.
 * 
 * @param coll  the collection to decorate, must not be null
 * @return a new synchronized collection
 * @throws IllegalArgumentException if collection is null
 */
public static Collection decorate(Collection coll) {
  return new SynchronizedCollection(coll);
}

origin: commons-collections/commons-collections

public void testToCollection() {
  setUpTest();
  one.add("1");
  two.add("2");
  c.addComposited(one, two);
  Collection foo = c.toCollection();
  assertTrue(foo.containsAll(c));
  assertEquals(c.size(), foo.size());
  one.add("3");
  assertTrue(!foo.containsAll(c));
}

origin: commons-collections/commons-collections

public void testRemove() {
  setUpMutatorTest();
  one.add("1");
  two.add("2");
  two.add("1");
  c.addComposited(one, two);
  c.remove("1");
  assertTrue(!c.contains("1"));
  assertTrue(!one.contains("1"));
  assertTrue(!two.contains("1"));
}

origin: commons-collections/commons-collections

public void testIsEmpty() {
  setUpTest();
  assertTrue(c.isEmpty());
  HashSet empty = new HashSet();
  c.addComposited(empty);
  assertTrue(c.isEmpty());
  empty.add("a");
  assertTrue(!c.isEmpty());
}

origin: commons-collections/commons-collections

/**
 * Empty collection is empty composite
 */
public Collection makeCollection() {
  return new CompositeCollection();
}

origin: commons-collections/commons-collections

public void testContainsAll() {
  setUpTest();
  one.add("1");
  two.add("1");
  c.addComposited(one);
  assertTrue(c.containsAll(two));
}

origin: commons-collections/commons-collections

/**
 * Returns an unmodifiable collection backed by the given collection.
 * <p>
 * This method uses the implementation in the decorators subpackage.
 *
 * @param collection  the collection to make unmodifiable, must not be null
 * @return an unmodifiable collection backed by the given collection
 * @throws IllegalArgumentException  if the collection is null
 */
public static Collection unmodifiableCollection(Collection collection) {
  return UnmodifiableCollection.decorate(collection);
}
origin: commons-collections/commons-collections

/**
 * Returns a typed collection backed by the given collection.
 * <p>
 * Only objects of the specified type can be added to the collection.
 * 
 * @param collection  the collection to limit to a specific type, must not be null
 * @param type  the type of objects which may be added to the collection
 * @return a typed collection backed by the specified collection
 */
public static Collection typedCollection(Collection collection, Class type) {
  return TypedCollection.decorate(collection, type);
}

origin: commons-collections/commons-collections

/**
 * This can receive either a <code>CompositeCollection.CollectionMutator</code>
 * or a <code>CompositeSet.SetMutator</code>. If a
 * <code>CompositeCollection.CollectionMutator</code> is used than conflicts when adding
 * composited sets will throw IllegalArgumentException
 * <p>
 */
public void setMutator(CollectionMutator mutator) {
  super.setMutator(mutator);
}

origin: commons-collections/commons-collections

public static Test suite() {
  TestSuite suite = new TestSuite();
  
  suite.addTest(TestCompositeCollection.suite());
  suite.addTest(TestPredicatedCollection.suite());
  suite.addTest(TestSynchronizedCollection.suite());
  suite.addTest(TestTransformedCollection.suite());
  suite.addTest(TestUnmodifiableCollection.suite());
  
  return suite;
}
  
origin: commons-collections/commons-collections

/**
 *  Resets the {@link #collection} and {@link #confirmed} fields to full
 *  collections.  Invoke this method before performing a modification
 *  test.
 */
public void resetFull() {
  this.collection = makeFullCollection();
  this.confirmed = makeConfirmedFullCollection();
}
origin: commons-collections/commons-collections

/**
 *  Resets the {@link #collection} and {@link #confirmed} fields to empty
 *  collections.  Invoke this method before performing a modification
 *  test.
 */
public void resetEmpty() {
  this.collection = makeCollection();
  this.confirmed = makeConfirmedCollection();
}
origin: commons-collections/commons-collections

/**
 *  Returns an array of elements that are <I>not</I> contained in a
 *  full collection.  Every element in the returned array must 
 *  not exist in a collection returned by {@link #makeFullCollection()}.
 *  The default implementation returns a heterogenous array of elements
 *  without null.  Note that some of the tests add these elements
 *  to an empty or full collection, so if your collection restricts
 *  certain kinds of elements, you should override this method.
 */
public Object[] getOtherElements() {
  return getOtherNonNullElements();
}

origin: commons-collections/commons-collections

/**
 *  Returns an empty collection for Object tests.
 */
public Object makeObject() {
  return makeCollection();
}
origin: commons-collections/commons-collections

/**
 * Create a CompositeCollection with colls as the initial list of
 * composited collections.
 * 
 * @param colls  an array of collections to decorate
 */
public CompositeCollection(Collection[] colls) {
  this();
  this.addComposited(colls);
}

origin: commons-collections/commons-collections

public void testClear() {
  setUpTest();
  one.add("1");
  two.add("2");
  c.addComposited(one, two);
  c.clear();
  assertTrue(one.isEmpty());
  assertTrue(two.isEmpty());
  assertTrue(c.isEmpty());
}

origin: commons-collections/commons-collections

/**
 * Add two additional collections to this composite.
 * 
 * @param c  the first collection to add
 * @param d  the second collection to add
 */
public void addComposited(Collection c, Collection d) {
  this.addComposited(new Collection[]{c, d});
}

origin: commons-collections/commons-collections

/**
 * Add an additional collection to this composite.
 * 
 * @param c  the collection to add
 */
public void addComposited(Collection c) {
  this.addComposited(new Collection[]{c});
}

org.apache.commons.collections.collection

Most used classes

  • CompositeCollection
    Decorates a collection of other collections to provide a single unified view. Changes made to this
  • UnmodifiableCollection
    Decorates another Collection to ensure it can't be altered. This class is Serializable from Commons
  • TransformedCollection
    Decorates another Collection to transform objects that are added. The add methods are affected by th
  • PredicatedCollection
    Decorates another Collection to validate that additions match a specified predicate. This collection
  • SynchronizedCollection
    Decorates another Collection to synchronize its behaviour for a multi-threaded environment. Iterator
  • UnmodifiableBoundedCollection,
  • CompositeCollection$CollectionMutator,
  • AbstractTestCollection,
  • TestAll,
  • TestCompositeCollection,
  • TestPredicatedCollection,
  • TestSynchronizedCollection,
  • TestTransformedCollection,
  • TestUnmodifiableCollection
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now