All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.jimple.infoflow.collect.BlackHoleCollection Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
package soot.jimple.infoflow.collect;

import java.util.Collection;
import java.util.Iterator;

/**
 * This collection does nothing. You can add elements to it, but they won't be
 * stored. This collection is useful if you have to supply a collection to some
 * API method, but you don't really care about what gets added to the collection.
 * 
 * @author Steven Arzt
 *
 * @param  The type of elements in the collection
 */
public class BlackHoleCollection implements Collection {

	@Override
	public int size() {
		return 0;
	}

	@Override
	public boolean isEmpty() {
		return true;
	}

	@Override
	public boolean contains(Object o) {
		return false;
	}

	@Override
	public Iterator iterator() {
		return new Iterator() {

			@Override
			public boolean hasNext() {
				return false;
			}

			@Override
			public E next() {
				return null;
			}
			
			@Override
			public void remove() {
			}
			
		};
	}

	@Override
	public Object[] toArray() {
		return new Object[0];
	}

	@Override
	public  T[] toArray(T[] a) {
		return a;
	}

	@Override
	public boolean add(E e) {
		return true;
	}

	@Override
	public boolean remove(Object o) {
		return false;
	}

	@Override
	public boolean containsAll(Collection c) {
		return false;
	}

	@Override
	public boolean addAll(Collection c) {
		return true;
	}

	@Override
	public boolean removeAll(Collection c) {
		return false;
	}

	@Override
	public boolean retainAll(Collection c) {
		return false;
	}

	@Override
	public void clear() {
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy