From 781b909d1cec192826985882a7a6ac54ff7ece48 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 13 Oct 2016 21:25:08 +0200 Subject: [PATCH] MetadataPathSelector: Fix issue reported by Coverity (missing break) 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 --- .../copier/MetadataPathSelector.java | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/Goobi/src/de/sub/goobi/metadaten/copier/MetadataPathSelector.java b/Goobi/src/de/sub/goobi/metadaten/copier/MetadataPathSelector.java index 872c0ba84cd..4ad8d41fa07 100644 --- a/Goobi/src/de/sub/goobi/metadaten/copier/MetadataPathSelector.java +++ b/Goobi/src/de/sub/goobi/metadaten/copier/MetadataPathSelector.java @@ -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; } /**