* @return true if a rule was successfully removed, false otherwise
*/
public boolean remove(Predicate p) {
if ( p == null ) return false;
IfExpression prev = null;
Expression expr = m_head;
while ( expr instanceof IfExpression ) {
IfExpression ifex = (IfExpression)expr;
Predicate test = (Predicate)ifex.getTestPredicate();
if ( p.equals(test) ) {
Expression elseex = ifex.getElseExpression();
ifex.setElseExpression(new ObjectLiteral(null));
if ( prev != null ) {
prev.setElseExpression(elseex);
if ( ifex == m_tail )
m_tail = prev;
} else {
m_head = elseex;
if ( ifex == m_tail )
m_tail = null;
}
return true;
} else {
prev = ifex;
expr = ifex.getElseExpression();
}
}
return false;
}