import com.google.common.collect.Iterables;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.model.api.ContainerLike;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
return new InstanceIdentifierContext(context, rpc, null);
}
+ // Invocations of various identifier-less details
+ public static @NonNull InstanceIdentifierContext ofDataSchemaNode(final EffectiveModelContext context,
+ final DataSchemaNode schemaNode) {
+ return new InstanceIdentifierContext(null, requireNonNull(schemaNode), null, requireNonNull(context));
+ }
+
+ // Invocations of various identifier-less details, potentially having a mount point
+ public static @NonNull InstanceIdentifierContext ofDataSchemaNode(final EffectiveModelContext context,
+ final DataSchemaNode schemaNode, final @Nullable DOMMountPoint mountPoint) {
+ return new InstanceIdentifierContext(null, requireNonNull(schemaNode), mountPoint, requireNonNull(context));
+ }
+
public static @NonNull InstanceIdentifierContext ofLocalRpcInput(final EffectiveModelContext context,
// FIXME: this this method really needed?
final RpcDefinition rpc) {
}
errContBuild.withChild(listErorsBuilder.build());
- final NormalizedNodeContext errContext = new NormalizedNodeContext(new InstanceIdentifierContext(null,
- (DataSchemaNode) errorsSchemaNode, null, controllerContext.getGlobalSchema()), errContBuild.build());
+ final NormalizedNodeContext errContext = new NormalizedNodeContext(InstanceIdentifierContext.ofDataSchemaNode(
+ controllerContext.getGlobalSchema(), (DataSchemaNode) errorsSchemaNode), errContBuild.build());
Object responseBody;
if (mediaType.getSubtype().endsWith("json")) {
SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) modulesSchemaNode);
moduleContainerBuilder.withChild(allModuleMap);
- return new NormalizedNodeContext(new InstanceIdentifierContext(null, modulesSchemaNode, null, schemaContext),
+ return new NormalizedNodeContext(InstanceIdentifierContext.ofDataSchemaNode(schemaContext, modulesSchemaNode),
moduleContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
checkState(moduleSchemaNode instanceof ListSchemaNode);
return new NormalizedNodeContext(
- new InstanceIdentifierContext(null, moduleSchemaNode, mountPoint, schemaContext), moduleMap,
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContext, moduleSchemaNode, mountPoint), moduleMap,
QueryParametersParser.parseWriterParameters(uriInfo));
}
streamsContainerBuilder.withChild(listStreamsBuilder.build());
return new NormalizedNodeContext(
- new InstanceIdentifierContext(null, streamsContainerSchemaNode, null, schemaContext),
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContext, streamsContainerSchemaNode),
streamsContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
testNodeContainer.withChild(leafKey2.build());
}
- final NormalizedNodeContext testCompositeContext = new NormalizedNodeContext(new InstanceIdentifierContext(
- null, testNodeSchemaNode, null, schemaContextTestModule), testNodeContainer.build());
+ final NormalizedNodeContext testCompositeContext = new NormalizedNodeContext(
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContextTestModule, testNodeSchemaNode),
+ testNodeContainer.build());
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
restconfImpl.updateConfigurationData(toUri(uriKey1, uriKey2), testCompositeContext, uriInfo);
.withValue("/instanceidentifier/").build());
dataCont.withChild(dataCont1.build());
- final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(
- new InstanceIdentifierContext(null, schemaCont,
- null, schemaContext), dataCont.build());
-
- return testNormalizedNodeContext;
+ return new NormalizedNodeContext(InstanceIdentifierContext.ofDataSchemaNode(schemaContext, schemaCont),
+ dataCont.build());
}
@Test
dataCont1.withChild(dataLst11.build());
dataCont.withChild(dataCont1.build());
- return new NormalizedNodeContext(new InstanceIdentifierContext(null, schemaCont, null, schemaContext),
+ return new NormalizedNodeContext(InstanceIdentifierContext.ofDataSchemaNode(schemaContext, schemaCont),
dataCont.build());
}
contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(object).build());
- final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(
- new InstanceIdentifierContext(null, contSchema, null, schemaContext), contData.build());
-
- return testNormalizedNodeContext;
+ return new NormalizedNodeContext(InstanceIdentifierContext.ofDataSchemaNode(schemaContext, contSchema),
+ contData.build());
}
private void nnToXml(final NormalizedNodeContext normalizedNodeContext, final String... xmlRepresentation)
contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue("true").build());
final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(
- new InstanceIdentifierContext(null, contSchema, null, schemaContext), contData.build());
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContext, contSchema), contData.build());
return testNormalizedNodeContext;
}
contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue("value").build());
return new NormalizedNodeContext(
- new InstanceIdentifierContext(null, contSchema, null, schemaContext), contData.build());
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContext, contSchema), contData.build());
}
private static NormalizedNodeContext prepareIdrefData(final String prefix, final boolean valueAsQName) {
contData.withChild(cont1Data.build());
final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(
- new InstanceIdentifierContext(null, contSchema, null, schemaContext), contData.build());
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContext, contSchema), contData.build());
return testNormalizedNodeContext;
}
dataContainerNodeAttrBuilder.withChild(dataChoice.build());
final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(
- new InstanceIdentifierContext(null, contSchemaNode, null, schemaContext),
+ InstanceIdentifierContext.ofDataSchemaNode(schemaContext, contSchemaNode),
dataContainerNodeAttrBuilder.build());
return testNormalizedNodeContext;