package org.concord.framework.otrunk;

import java.util.Vector;

/**
 * A simple abstract class for being able to define a filtering mechanism for an OTObject or OTObjectList
 * 
 * @author aunger
 */
public abstract class OTObjectFilter {

	abstract public boolean keepObject(OTObject obj);
	
	public Vector<OTObject> filterList(OTObjectList list) {
		Vector<OTObject> originalList = list.getVector();
		return filterList(originalList);
	}
	
	public Vector<OTObject> filterList(Vector<OTObject> list) {
		Vector<OTObject> filtered = new Vector<OTObject>();
		for (OTObject obj : list) {
			if (keepObject(obj)) {
				filtered.add(obj);
			}
		}
		return filtered;
	}
}

package org.concord.framework.otrunk;

import java.util.Vector;

/**
 * A simple abstract class for being able to define a filtering mechanism for an OTObject or OTObjectList
 * 
 * @author aunger
 */
public abstract class OTObjectFilter {

	abstract public boolean keepObject(OTObject obj);
	
	public Vector<OTObject> filterList(OTObjectList list) {
		Vector<OTObject> originalList = list.getVector();
		return filterList(originalList);
	}
	
	public Vector<OTObject> filterList(Vector<OTObject> list) {
		Vector<OTObject> filtered = new Vector<OTObject>();
		for (OTObject obj : list) {
			if (obj != null && keepObject(obj)) {
				filtered.add(obj);
			}
		}
		return filtered;
	}
}

Check if filter obj is null to avoid NPE
Check if filter obj is null to avoid NPE

git-svn-id: fdf63cc6b6871a635be2b727c8623e4c3a9a9ed7@18222 6e01202a-0783-4428-890a-84243c50cc2b
