Useing a switch expression removes the unhandled case, promoting to a
compile-time error if things do not match up.
Change-Id: I8688e4bc76419194cb0d910105ff0733cd6d118f
Signed-off-by: Robert Varga <[email protected]>
}
private static DataTreeCandidateFormatterFactory getFormatterFactory(final NotificationOutputType outputType) {
- switch (outputType) {
- case JSON:
- return JSON_FORMATTER_FACTORY;
- case XML:
- return XMLDataTreeCandidateFormatter.FACTORY;
- default:
- throw new IllegalArgumentException("Unsupported outputType" + outputType);
- }
+ return switch (outputType) {
+ case JSON -> JSON_FORMATTER_FACTORY;
+ case XML -> XMLDataTreeCandidateFormatter.FACTORY;
+ };
}
@Override
}
private static NotificationFormatterFactory getFormatterFactory(final NotificationOutputType outputType) {
- switch (outputType) {
- case JSON:
- return JSON_FORMATTER_FACTORY;
- case XML:
- return XMLNotificationFormatter.FACTORY;
- default:
- throw new IllegalArgumentException("Unsupported outputType " + outputType);
- }
+ return switch (outputType) {
+ case JSON -> JSON_FORMATTER_FACTORY;
+ case XML -> XMLNotificationFormatter.FACTORY;
+ };
}
@Override