This is a faster way of checking if an InstanceIdentifier is empty
than comparison to a constant.
Change-Id: I095576cdf1ac522348f3befaa8b14e84feaddf1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
Preconditions.checkState(type != TransactionType.WRITE_ONLY,
"Reads from write-only transactions are not allowed");
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
Preconditions.checkState(type != TransactionType.WRITE_ONLY,
"Reads from write-only transactions are not allowed");
+ Preconditions.checkNotNull(path, "path should not be null");
LOG.trace("Tx {} read {}", getIdentifier(), path);
LOG.trace("Tx {} read {}", getIdentifier(), path);
-
- if (YangInstanceIdentifier.EMPTY.equals(path)) {
- return readAllData();
- } else {
- return singleShardRead(shardNameFromIdentifier(path), path);
- }
+ return path.isEmpty() ? readAllData() : singleShardRead(shardNameFromIdentifier(path), path);
}
private CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> singleShardRead(
}
private CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> singleShardRead(