1 18 19 package de.gulden.framework.amoda.generic.behaviour; 20 21 import de.gulden.framework.amoda.model.behaviour.Condition; 22 import java.lang.*; 23 import java.util.*; 24 25 31 public abstract class GenericCondition extends GenericBehaviourMemberAbstract implements Condition { 32 33 37 protected Object object; 38 39 40 44 public abstract boolean test(); 45 46 public boolean test(Object o) { 47 setObject(o); 48 return test(); 49 } 50 51 public Object getObject() { 52 return object; 53 } 54 55 public void setObject(Object _object) { 56 object = _object; 57 } 58 59 public Collection filter(Collection c) { 60 ArrayList result = new ArrayList(); 61 for (Iterator it = c.iterator(); it.hasNext(); ) { 62 Object o = it.next(); 63 this.setObject(o); 64 if (this.test()) { 65 result.add(o); 66 } 67 } 68 return result; 69 } 70 71 } | Popular Tags |