X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fapi%2Fschema%2Ftree%2FCursorAwareDataTreeModification.java;h=e03056ea989413938ba06276f4b03461e0da450e;hb=1489f5570dde3c047e3542e6d70b1ecb4aac5c32;hp=9154d0a273a011613d4a77d6e3d526157b4a65f1;hpb=0d28b86a25b8cdbaf95355e07774412aa4689211;p=yangtools.git diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/CursorAwareDataTreeModification.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/CursorAwareDataTreeModification.java index 9154d0a273..e03056ea98 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/CursorAwareDataTreeModification.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/CursorAwareDataTreeModification.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.data.api.schema.tree; import com.google.common.annotations.Beta; +import java.util.Optional; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -21,12 +22,38 @@ public interface CursorAwareDataTreeModification extends DataTreeModification, C * Create a new {@link DataTreeModificationCursor} at specified path. May fail * if specified path does not exist. It is a programming error to use normal * - * * @param path Path at which the cursor is to be anchored * @return A new cursor, or null if the path does not exist. * @throws IllegalStateException if there is another cursor currently open, * or the modification is already {@link #ready()}. + * @deprecated Use {@link #openCursor(YangInstanceIdentifier)} instead. */ + @Deprecated @Override @Nullable DataTreeModificationCursor createCursor(@Nonnull YangInstanceIdentifier path); + + /** + * Create a new {@link DataTreeModificationCursor} at specified path. May fail + * if specified path does not exist. + * + * @param path Path at which the cursor is to be anchored + * @return A new cursor, or empty if the path does not exist. + * @throws IllegalStateException if there is another cursor currently open, + * or the modification is already {@link #ready()}. + */ + @Override + default Optional openCursor(@Nonnull final YangInstanceIdentifier path) { + return Optional.ofNullable(createCursor(path)); + } + + /** + * Create a new {@link DataTreeModificationCursor} at the root of the modification. + * + * @return A new cursor + * @throws IllegalStateException if there is another cursor currently open. + */ + @Override + default DataTreeModificationCursor openCursor() { + return openCursor(YangInstanceIdentifier.EMPTY).get(); + } }