Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5596f75 authored by cketti's avatar cketti
Browse files

Remove checked exceptions from LocalSearch and ConditionsTreeNode

parent a7acc09e
Loading
Loading
Loading
Loading
+9 −21
Original line number Diff line number Diff line
@@ -164,9 +164,8 @@ public class ConditionsTreeNode implements Parcelable {
     *
     * @param expr Expression to 'AND' with.
     * @return New top AND node.
     * @throws Exception
     */
    public ConditionsTreeNode and(ConditionsTreeNode expr) throws Exception {
    public ConditionsTreeNode and(ConditionsTreeNode expr) {
        return add(expr, Operator.AND);
    }

@@ -179,13 +178,8 @@ public class ConditionsTreeNode implements Parcelable {
     * @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;
        }
    }

    /**
@@ -194,9 +188,8 @@ public class ConditionsTreeNode implements Parcelable {
     *
     * @param expr Expression to 'OR' with.
     * @return New top OR node.
     * @throws Exception
     */
    public ConditionsTreeNode or(ConditionsTreeNode expr) throws Exception {
    public ConditionsTreeNode or(ConditionsTreeNode expr) {
        return add(expr, Operator.OR);
    }

@@ -209,13 +202,8 @@ public class ConditionsTreeNode implements Parcelable {
     * @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;
        }
    }

    /**
@@ -295,11 +283,11 @@ public class ConditionsTreeNode implements Parcelable {
     * @param node Node to add.
     * @param op Operator that will connect the new node with this one.
     * @return New parent node, containing the operator.
     * @throws Exception Throws when the provided new node does not have a null parent.
     * @throws IllegalArgumentException Throws when the provided new node does not have a null parent.
     */
    private ConditionsTreeNode add(ConditionsTreeNode node, Operator op) throws Exception {
    private ConditionsTreeNode add(ConditionsTreeNode node, Operator op) {
        if (node.mParent != null) {
            throw new Exception("Can only add new expressions from root node down.");
            throw new IllegalArgumentException("Can only add new expressions from root node down.");
        }

        ConditionsTreeNode tmpNode = new ConditionsTreeNode(mParent, op);
+6 −18
Original line number Diff line number Diff line
@@ -170,13 +170,8 @@ public class LocalSearch implements SearchSpecification {
     * @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;
        }
    }

    /**
@@ -185,9 +180,8 @@ public class LocalSearch implements SearchSpecification {
     *
     * @param node Node to 'AND' with.
     * @return New top AND node, new root.
     * @throws Exception
     */
    public ConditionsTreeNode and(ConditionsTreeNode node) throws Exception {
    public ConditionsTreeNode and(ConditionsTreeNode node) {
        mLeafSet.addAll(node.getLeafSet());

        if (mConditions == null) {
@@ -207,13 +201,8 @@ public class LocalSearch implements SearchSpecification {
     * @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;
        }
    }

    /**
@@ -222,9 +211,8 @@ public class LocalSearch implements SearchSpecification {
     *
     * @param node Node to 'OR' with.
     * @return New top OR node, new root.
     * @throws Exception
     */
    public ConditionsTreeNode or(ConditionsTreeNode node) throws Exception {
    public ConditionsTreeNode or(ConditionsTreeNode node) {
        mLeafSet.addAll(node.getLeafSet());

        if (mConditions == null) {