From 331797328ab14acaa39efa7fdfb0e571860baca9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 25 May 2018 13:47:10 +0200 Subject: [PATCH] Improve InstanceIdentifier documentation This adds a few javadocs to clarify what is going on. Change-Id: I9983e7d6715fc06c7d18a61fd74a0660c8d2b4ce Signed-off-by: Robert Varga --- .../yang/binding/InstanceIdentifier.java | 76 ++++++++++++++----- 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java index 5dfbfb8513..11b77cc5a0 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java @@ -343,15 +343,45 @@ public class InstanceIdentifier implements Path Container type + * @return An InstanceIdentifier. + * @throws NullPointerException if {@code container} is null + */ public final > InstanceIdentifier child(final Class container) { return childIdentifier(new Item<>(container)); } + /** + * Create an InstanceIdentifier for a child list item. This method is a more efficient equivalent to + * {@code builder().child(listItem, listKey).build()}. + * + * @param listItem List to append + * @param listKey List key + * @param List type + * @param Key type + * @return An InstanceIdentifier. + * @throws NullPointerException if any argument is null + */ + @SuppressWarnings("unchecked") public final & ChildOf, K extends Identifier> KeyedInstanceIdentifier child(final Class listItem, final K listKey) { return (KeyedInstanceIdentifier) childIdentifier(new IdentifiableItem<>(listItem, listKey)); } + /** + * Create an InstanceIdentifier for a child augmentation. This method is a more efficient equivalent to + * {@code builder().augmentation(container).build()}. + * + * @param container Container to append + * @param Container type + * @return An InstanceIdentifier. + * @throws NullPointerException if {@code container} is null + */ public final > InstanceIdentifier augmentation( final Class container) { return childIdentifier(new Item<>(container)); @@ -398,7 +428,8 @@ public class InstanceIdentifier implements Path Type of the container - * @return New IsntanceIdentifierBuilder + * @return A new {@link InstanceIdentifierBuilder} + * @throws NullPointerException if {@code container} is null */ public static > InstanceIdentifierBuilder builder( final Class container) { @@ -414,6 +445,7 @@ public class InstanceIdentifier implements Path List type * @param List key * @return A new {@link InstanceIdentifierBuilder} + * @throws NullPointerException if any argument is null */ public static & ChildOf, K extends Identifier> InstanceIdentifierBuilder builder(final Class listItem, final K listKey) { @@ -427,6 +459,7 @@ public class InstanceIdentifier implements Path internalCreate(final Iterable pathArguments) { final Iterator it = requireNonNull(pathArguments, "pathArguments may not be null") @@ -471,9 +504,9 @@ public class InstanceIdentifier implements Path immutableArguments = (Iterable) pathArguments; return internalCreate(immutableArguments); - } else { - return internalCreate(ImmutableList.copyOf(pathArguments)); } + + return internalCreate(ImmutableList.copyOf(pathArguments)); } /** @@ -534,6 +567,11 @@ public class InstanceIdentifier implements Path { + /** + * Return the data object type backing this PathArgument. + * + * @return Data object type. + */ Class getType(); } @@ -612,6 +650,11 @@ public class InstanceIdentifier implements Path implements Path extends Builder> { /** * Append the specified container as a child of the current InstanceIdentifier referenced by the builder. @@ -643,18 +685,17 @@ public class InstanceIdentifier implements Path * InstanceIdentifier.builder().child(Nodes.class).build(); - * * * * NOTE :- The above example is only for illustration purposes InstanceIdentifier.builder() has been deprecated * and should not be used. Use InstanceIdentifier.builder(Nodes.class) instead * - * @param container - * @param - * @return + * @param container Container to append + * @param Container type + * @return this builder + * @throws NullPointerException if {@code container} is null */ - > InstanceIdentifierBuilder child( - Class container); + > InstanceIdentifierBuilder child(Class container); /** * Append the specified listItem as a child of the current InstanceIdentifier referenced by the builder. @@ -662,11 +703,12 @@ public class InstanceIdentifier implements Path - * @param - * @return + * @param listItem List to append + * @param listKey List key + * @param List type + * @param Key type + * @return this builder + * @throws NullPointerException if any argument is null */ & ChildOf, K extends Identifier> InstanceIdentifierBuilder child( Class listItem, K listKey); @@ -678,9 +720,9 @@ public class InstanceIdentifier implements Path augmentation type * @return this builder + * @throws NullPointerException if {@code container} is null */ - > InstanceIdentifierBuilder augmentation( - Class container); + > InstanceIdentifierBuilder augmentation(Class container); /** * Build the instance identifier. -- 2.36.6