- // FIXME: use a switch expression when they are available, removing source of RestconfDocumentedException
- switch (content) {
- case ALL:
- return readAllData(strategy, path, withDefa, ctx, fields);
- case CONFIG:
- final NormalizedNode read = readDataViaTransaction(strategy, LogicalDatastoreType.CONFIGURATION, path,
- fields);
- return withDefa == null ? read : prepareDataByParamWithDef(read, path, withDefa, ctx);
- case NONCONFIG:
- return readDataViaTransaction(strategy, LogicalDatastoreType.OPERATIONAL, path, fields);
- default:
- throw new RestconfDocumentedException(new RestconfError(ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- "Invalid content parameter: " + content.paramValue(), null,
- "The content parameter value must be either config, nonconfig or all (default)"));
- }
+ return switch (content) {
+ case ALL -> readAllData(strategy, path, withDefa, ctx, fields);
+ case CONFIG -> {
+ final var read = readDataViaTransaction(strategy, LogicalDatastoreType.CONFIGURATION, path, fields);
+ yield withDefa == null ? read : prepareDataByParamWithDef(read, path, withDefa, ctx);
+ }
+ case NONCONFIG -> readDataViaTransaction(strategy, LogicalDatastoreType.OPERATIONAL, path, fields);
+ };