Merge pull request #3723 from k9mail/LocalSearch_remove_checked_exceptions

Remove checked exceptions from LocalSearch and ConditionsTreeNode
This commit is contained in:
cketti 2018-11-18 20:21:05 +01:00 committed by GitHub
commit b79d7ea6e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 39 deletions

View file

@ -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;
}
ConditionsTreeNode tmp = new ConditionsTreeNode(condition);
return and(tmp);
}
/**
@ -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;
}
ConditionsTreeNode tmp = new ConditionsTreeNode(condition);
return or(tmp);
}
/**
@ -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);

View file

@ -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;
}
ConditionsTreeNode tmp = new ConditionsTreeNode(condition);
return and(tmp);
}
/**
@ -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;
}
ConditionsTreeNode tmp = new ConditionsTreeNode(condition);
return or(tmp);
}
/**
@ -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) {