import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
Preconditions.checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not "
+ "set properly (Schema Path is NULL)");
- final QName qname = Iterables.getFirst(schemaNode.getPath().getPathTowardsRoot(), null);
+ final QName qname = schemaNode.getPath().getLastComponent();
Preconditions.checkState(qname != null,
"Schema Path contains invalid state of path parts. " +
"The Schema Path MUST contain at least ONE QName which defines namespace and Local name of path.");
* @return Notification schema or null, if notification is not present in schema context.
*/
@Beta
- public static @Nullable NotificationDefinition getNotificationSchema(@Nonnull final SchemaContext schema,@Nonnull final SchemaPath path) {
+ @Nullable public static NotificationDefinition getNotificationSchema(@Nonnull final SchemaContext schema, @Nonnull final SchemaPath path) {
Preconditions.checkNotNull(schema, "Schema context must not be null.");
Preconditions.checkNotNull(path, "Schema path must not be null.");
for (final NotificationDefinition potential : schema.getNotifications()) {
* @return Notification schema or null, if notification is not present in schema context.
*/
@Beta
- public static @Nullable ContainerSchemaNode getRpcDataSchema(@Nonnull final SchemaContext schema,@Nonnull final SchemaPath path) {
+ @Nullable public static ContainerSchemaNode getRpcDataSchema(@Nonnull final SchemaContext schema, @Nonnull final SchemaPath path) {
Preconditions.checkNotNull(schema, "Schema context must not be null.");
Preconditions.checkNotNull(path, "Schema path must not be null.");
final Iterator<QName> it = path.getPathFromRoot().iterator();
}
}
+ private static final Pattern STRIP_PATTERN = Pattern.compile("\\[.*\\]");
+
/**
* Removes conditions from xPath pointed to target node.
*
*
*/
private static String stripConditionsFromXPathString(final RevisionAwareXPath pathStatement) {
- return pathStatement.toString().replaceAll("\\[.*\\]", "");
+ return STRIP_PATTERN.matcher(pathStatement.toString()).replaceAll("");
}
/**