[Minor] Automated Code cleanup: Minimum 'switch' branches
This commit is contained in:
parent
c3e76731d9
commit
e77f4e5da9
|
@ -70,10 +70,8 @@ public class StrolchPolicyFileParser extends DefaultHandler {
|
|||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
switch (qName) {
|
||||
case POLICY_TYPE -> this.policyType = null;
|
||||
default -> {
|
||||
}
|
||||
if (qName.equals(POLICY_TYPE)) {
|
||||
this.policyType = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,13 +70,12 @@ public class XmlModelSaxStreamReader extends XmlModelSaxReader {
|
|||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
|
||||
switch (qName) {
|
||||
case Tags.INCLUDE_FILE -> {
|
||||
if (qName.equals(Tags.INCLUDE_FILE)) {
|
||||
String msg = "The {0} can''t handle Tags of type {1}";
|
||||
msg = MessageFormat.format(msg, XmlModelSaxStreamReader.class.getName(), Tags.INCLUDE_FILE);
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
default -> super.startElement(uri, localName, qName, attributes);
|
||||
} else {
|
||||
super.startElement(uri, localName, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -244,18 +244,15 @@ public class PrivilegeUsersSaxReader extends DefaultHandler {
|
|||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||
|
||||
switch (qName) {
|
||||
case XML_PROPERTY -> {
|
||||
if (qName.equals(XML_PROPERTY)) {
|
||||
String key = attributes.getValue(XML_ATTR_NAME).trim();
|
||||
String value = attributes.getValue(XML_ATTR_VALUE).trim();
|
||||
this.parameterMap.put(key, value);
|
||||
}
|
||||
default -> {
|
||||
} else {
|
||||
if (!qName.equals(XML_PROPERTIES)) {
|
||||
throw new IllegalArgumentException("Unhandled tag " + qName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getParameterMap() {
|
||||
|
|
|
@ -132,12 +132,8 @@ public class GenericReportTest {
|
|||
.forEach(e -> {
|
||||
|
||||
String slotName = e.get("slot").getAsString();
|
||||
switch (slotName) {
|
||||
case "Slot 3":
|
||||
break;
|
||||
default:
|
||||
if (!slotName.equals("Slot 3")) {
|
||||
fail("Unexpected slot name " + slotName + ", should have been filtered!");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ public class BookSaxParser extends DefaultHandler implements SaxParser<Book> {
|
|||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||
|
||||
switch (qName) {
|
||||
case "Book" -> {
|
||||
if (qName.equals("Book")) {
|
||||
String idS = attributes.getValue("id");
|
||||
long id = Long.parseLong(idS);
|
||||
Book book = new Book(id);
|
||||
|
@ -73,8 +72,8 @@ public class BookSaxParser extends DefaultHandler implements SaxParser<Book> {
|
|||
double price = Double.parseDouble(priceS);
|
||||
book.setPrice(price);
|
||||
this.book = book;
|
||||
}
|
||||
default -> throw new IllegalArgumentException("The element '" + qName + "' is unhandled!");
|
||||
} else {
|
||||
throw new IllegalArgumentException("The element '" + qName + "' is unhandled!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue