Skip to content

Commit

Permalink
MetadataPathSelector: Fix issue reported by Coverity (missing break)
Browse files Browse the repository at this point in the history
Coverity report:
CID 44654 (#1 of 1): Missing break in switch (MISSING_BREAK)

Moving the code for the default case out of the switch statement
and cleaning the if / else statements improves the readability.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 13, 2016
1 parent d6e9b45 commit 781b909
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions Goobi/src/de/sub/goobi/metadaten/copier/MetadataPathSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,26 +349,21 @@ private DocStruct getSubnode(DocStruct logicalNode) {
if (index == null || index.equals(0) || index.equals(Integer.MAX_VALUE)) {
return children.get(0);
}
default:
if (index == null) {
throw new RuntimeException("Could not resolve metadata path: Path selector is ambiguous for "
+ docStructType);
} else {
if (!(index instanceof Integer)) {
throw new RuntimeException("Could not resolve metadata path: In this regard, index \"" + index
+ "\" is not allowed.");
} else {
if (index.equals(Long.MAX_VALUE)) {
return children.get(children.size() - 1);
}
if (children.size() >= ((Integer) index).intValue()) {
return children.get(((Integer) index).intValue());
} else {
return null;
}
}
}
}

if (index == null) {
throw new RuntimeException("Could not resolve metadata path: Path selector is ambiguous for "
+ docStructType);
} else if (!(index instanceof Integer)) {
throw new RuntimeException("Could not resolve metadata path: In this regard, index \""
+ index + "\" is not allowed.");
} else if (index.equals(Long.MAX_VALUE)) {
return children.get(children.size() - 1);
} else if (children.size() >= ((Integer) index).intValue()) {
return children.get(((Integer) index).intValue());
}

return null;
}

/**
Expand Down

0 comments on commit 781b909

Please sign in to comment.