mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 20:15:03 -05:00
Added two convenience methods to avoid dealing with exceptions all the time.
This commit is contained in:
parent
9883148b2f
commit
bdfc9d6852
@ -141,6 +141,24 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
return add(expr, OPERATOR.AND);
|
return add(expr, OPERATOR.AND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method.
|
||||||
|
* Adds the provided condition as the second argument of an AND
|
||||||
|
* clause to this node.
|
||||||
|
*
|
||||||
|
* @param condition Condition to 'AND' with.
|
||||||
|
* @return New top AND node, new root.
|
||||||
|
*/
|
||||||
|
public ConditionsTreeNode and(SearchCondition condition) {
|
||||||
|
try {
|
||||||
|
ConditionsTreeNode tmp = new ConditionsTreeNode(condition);
|
||||||
|
return and(tmp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// impossible
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the expression as the second argument of an OR
|
* Adds the expression as the second argument of an OR
|
||||||
* clause to this node.
|
* clause to this node.
|
||||||
@ -153,6 +171,24 @@ public class ConditionsTreeNode implements Parcelable{
|
|||||||
return add(expr, OPERATOR.OR);
|
return add(expr, OPERATOR.OR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method.
|
||||||
|
* Adds the provided condition as the second argument of an OR
|
||||||
|
* clause to this node.
|
||||||
|
*
|
||||||
|
* @param condition Condition to 'OR' with.
|
||||||
|
* @return New top OR node, new root.
|
||||||
|
*/
|
||||||
|
public ConditionsTreeNode or(SearchCondition condition) {
|
||||||
|
try {
|
||||||
|
ConditionsTreeNode tmp = new ConditionsTreeNode(condition);
|
||||||
|
return or(tmp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// impossible
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This applies the MPTT labeling to the subtree of which this node
|
* This applies the MPTT labeling to the subtree of which this node
|
||||||
* is the root node.
|
* is the root node.
|
||||||
|
Loading…
Reference in New Issue
Block a user