import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
private static final Logger LOG = LoggerFactory.getLogger(ParserIdentifier.class);
+ private ParserIdentifier() {
+ throw new UnsupportedOperationException("Util class.");
+ }
+
/**
* Make {@link InstanceIdentifierContext} from identifier.
*
* - {@link SchemaContext}
* @return {@link InstanceIdentifierContext}
*/
- public static InstanceIdentifierContext<?> toInstanceIdentifier(final String identifier,
+ public static InstanceIdentifierContext<?> toInstanceIdentifier(@Nullable final String identifier,
final SchemaContext schemaContext) {
final YangInstanceIdentifier deserialize;
- if (identifier.contains(RestconfConstants.MOUNT)) {
+ if (identifier != null && identifier.contains(RestconfConstants.MOUNT)) {
final String mountPointId = identifier.substring(0, identifier.indexOf("/" + RestconfConstants.MOUNT));
deserialize = IdentifierCodec.deserialize(mountPointId, schemaContext);
} else {
return new InstanceIdentifierContext<SchemaNode>(deserialize, child.getDataSchemaNode(), null, schemaContext);
}
+ /**
+ * Make {@link String} from {@link YangInstanceIdentifier}
+ *
+ * @param instanceIdentifier
+ * @param schemaContext
+ * @return
+ */
+ public static String stringFromYangInstanceIdentifier(final YangInstanceIdentifier instanceIdentifier,
+ final SchemaContext schemaContext) {
+ return IdentifierCodec.serialize(instanceIdentifier, schemaContext);
+ }
+
/**
* Make a {@link QName} from identifier
*
final StringBuilder pathBuilder = new StringBuilder();
while (componentIter.hasNext()) {
final String current = componentIter.next();
- pathBuilder.append("/");
- pathBuilder.append(current);
+
if (RestconfConstants.MOUNT.equals(current)) {
+ pathBuilder.append("/");
+ pathBuilder.append(RestconfConstants.MOUNT);
break;
}
+
+ if (pathBuilder.length() != 0) {
+ pathBuilder.append("/");
+ }
+
+ pathBuilder.append(current);
}
final InstanceIdentifierContext<?> point = ParserIdentifier
.toInstanceIdentifier(pathBuilder.toString(), schemaContext);