本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.RpcDefinition.getInput方法的典型用法代码示例。如果您正苦于以下问题:Java RpcDefinition.getInput方法的具体用法?Java RpcDefinition.getInput怎么用?Java RpcDefinition.getInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.yang.model.api.RpcDefinition
的用法示例。
在下文中一共展示了RpcDefinition.getInput方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testImplicitInputAndOutput
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
@Test
public void testImplicitInputAndOutput() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rpc-stmt-test/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2016-11-25")).get();
final Set<RpcDefinition> rpcs = barModule.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition barRpc = rpcs.iterator().next();
final ContainerSchemaNode input = barRpc.getInput();
assertNotNull(input);
assertEquals(2, input.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
final ContainerSchemaNode output = barRpc.getOutput();
assertNotNull(output);
assertEquals(2, output.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());
}
示例2: from
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
public static RpcRoutingStrategy from(final RpcDefinition rpc) {
ContainerSchemaNode input = rpc.getInput();
if (input != null) {
for (DataSchemaNode schemaNode : input.getChildNodes()) {
Optional<QName> context = getRoutingContext(schemaNode);
if (context.isPresent()) {
return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName());
}
}
}
return new GlobalRpcStrategy(rpc.getQName());
}
示例3: findRpcMethod
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef)
throws NoSuchMethodException {
final String methodName = BindingMapping.getMethodName(rpcDef.getQName());
if ((rpcDef.getInput() != null) && isExplicitStatement(rpcDef.getInput())) {
final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput());
return key.getMethod(methodName, inputClz);
}
return key.getMethod(methodName);
}
示例4: testValidYang11Model
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
@Test
public void testValidYang11Model() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6871/foo.yang");
assertNotNull(schemaContext);
final Module foo = schemaContext.findModule("foo", Revision.of("2016-12-14")).get();
final Set<NotificationDefinition> notifications = foo.getNotifications();
assertEquals(1, notifications.size());
final NotificationDefinition myNotification = notifications.iterator().next();
Collection<MustDefinition> mustConstraints = myNotification.getMustConstraints();
assertEquals(2, mustConstraints.size());
final Set<RpcDefinition> rpcs = foo.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition myRpc = rpcs.iterator().next();
final ContainerSchemaNode input = myRpc.getInput();
assertNotNull(input);
mustConstraints = input.getMustConstraints();
assertEquals(2, mustConstraints.size());
final ContainerSchemaNode output = myRpc.getOutput();
assertNotNull(output);
mustConstraints = output.getMustConstraints();
assertEquals(2, mustConstraints.size());
}
示例5: testRpc
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
@Test
public void testRpc() {
Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
Set<RpcDefinition> rpcs = testModule.getRpcs();
assertEquals(1, rpcs.size());
RpcDefinition rpc = rpcs.iterator().next();
assertEquals("get-schema", rpc.getQName().getLocalName());
assertEquals(Optional.of("This operation is used to retrieve a schema from the\n"
+ "NETCONF server.\n"
+ "\n"
+ "Positive Response:\n"
+ "The NETCONF server returns the requested schema.\n"
+ "\n"
+ "Negative Response:\n"
+ "If requested schema does not exist, the <error-tag> is\n"
+ "'invalid-value'.\n"
+ "\n"
+ "If more than one schema matches the requested parameters, the\n"
+ "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
+ "'data-not-unique'."), rpc.getDescription());
ContainerSchemaNode input = rpc.getInput();
assertNotNull(input);
assertEquals(3, input.getChildNodes().size());
ContainerSchemaNode output = rpc.getOutput();
assertNotNull(output);
assertEquals(1, output.getChildNodes().size());
}
示例6: getRpcDataSchema
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
/**
* Returns RPC input or output schema based on supplied QName.
*
* @param rpc RPC Definition
* @param qname input or output QName with namespace same as RPC
* @return input or output schema. Returns null if RPC does not have input/output specified.
*/
@Nullable public static ContainerSchemaNode getRpcDataSchema(@Nonnull final RpcDefinition rpc,
@Nonnull final QName qname) {
requireNonNull(rpc, "Rpc Schema must not be null");
requireNonNull(qname, "QName must not be null");
switch (qname.getLocalName()) {
case "input":
return rpc.getInput();
case "output":
return rpc.getOutput();
default:
throw new IllegalArgumentException("Supplied qname " + qname
+ " does not represent rpc input or output.");
}
}
示例7: getIdentitiesToRpcs
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
private static Multimap<QName/* of identity */, RpcDefinition> getIdentitiesToRpcs(
final SchemaContext schemaCtx) {
Multimap<QName, RpcDefinition> result = HashMultimap.create();
for (Module currentModule : schemaCtx.getModules()) {
// Find all identities in current module for later identity->rpc mapping
Set<QName> allIdentitiesInModule =
Sets.newHashSet(Collections2.transform(currentModule.getIdentities(), SchemaNode::getQName));
for (RpcDefinition rpc : currentModule.getRpcs()) {
ContainerSchemaNode input = rpc.getInput();
if (input != null) {
for (UsesNode uses : input.getUses()) {
// Check if the rpc is config rpc by looking for input argument rpc-context-ref
Iterator<QName> pathFromRoot = uses.getGroupingPath().getPathFromRoot().iterator();
if (!pathFromRoot.hasNext() ||
!pathFromRoot.next().equals(ConfigConstants.RPC_CONTEXT_REF_GROUPING_QNAME)) {
continue;
}
for (SchemaNode refinedNode : uses.getRefines().values()) {
for (UnknownSchemaNode unknownSchemaNode : refinedNode
.getUnknownSchemaNodes()) {
if (ConfigConstants.RPC_CONTEXT_INSTANCE_EXTENSION_QNAME
.equals(unknownSchemaNode.getNodeType())) {
String localIdentityName = unknownSchemaNode
.getNodeParameter();
QName identityQName = QName.create(
currentModule.getNamespace(),
currentModule.getRevision(),
localIdentityName);
Preconditions.checkArgument(allIdentitiesInModule.contains(identityQName),
"Identity referenced by rpc not found. Identity: %s, rpc: %s", localIdentityName, rpc);
result.put(identityQName, rpc);
}
}
}
}
}
}
}
return result;
}
示例8: testDeviateAdd
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
@Test
public void testDeviateAdd() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSources(
sourceForResource("/deviation-resolution-test/deviation-add/foo.yang"),
sourceForResource("/deviation-resolution-test/deviation-add/bar.yang"));
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2017-01-20")).get();
final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-leaf-list"));
assertNotNull(myLeafList);
assertFalse(myLeafList.isConfiguration());
assertEquals(3, myLeafList.getDefaults().size());
final ElementCountConstraint constraint = myLeafList.getElementCountConstraint().get();
assertEquals(10, constraint.getMaxElements().intValue());
assertEquals(5, constraint.getMinElements().intValue());
assertNotNull(myLeafList.getType().getUnits());
final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-list"));
assertNotNull(myList);
assertEquals(2, myList.getUniqueConstraints().size());
final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-choice"));
assertNotNull(myChoice);
assertEquals("c2", myChoice.getDefaultCase().get().getQName().getLocalName());
final RpcDefinition myRpc = barModule.getRpcs().iterator().next();
final ContainerSchemaNode input = myRpc.getInput();
assertEquals(2, input.getMustConstraints().size());
final ContainerSchemaNode output = myRpc.getOutput();
assertEquals(2, output.getMustConstraints().size());
final NotificationDefinition myNotification = barModule.getNotifications().iterator().next();
assertEquals(2, myNotification.getMustConstraints().size());
final AnyXmlSchemaNode myAnyxml = (AnyXmlSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-anyxml"));
assertNotNull(myAnyxml);
assertTrue(myAnyxml.isMandatory());
assertEquals(2, myAnyxml.getUnknownSchemaNodes().size());
}
示例9: allRPCMethodsToGenType
import org.opendaylight.yangtools.yang.model.api.RpcDefinition; //导入方法依赖的package包/类
private List<Type> allRPCMethodsToGenType(final Module module) {
if (module == null) {
throw new IllegalArgumentException("Module reference cannot be NULL!");
}
if (module.getName() == null) {
throw new IllegalArgumentException("Module name cannot be NULL!");
}
if (module.getChildNodes() == null) {
throw new IllegalArgumentException("Reference to Set of RPC Method Definitions in module "
+ module.getName() + " cannot be NULL!");
}
final String basePackageName = moduleNamespaceToPackageName(module);
final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
final List<Type> genRPCTypes = new ArrayList<>();
final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module, "Service");
final Type future = Types.typeForClass(Future.class);
for (final RpcDefinition rpc : rpcDefinitions) {
if (rpc != null) {
String rpcName = parseToClassName(rpc.getQName().getLocalName());
String rpcMethodName = parseToValidParamName(rpcName);
MethodSignatureBuilder method = interfaceBuilder.addMethod(rpcMethodName);
final List<DataNodeIterator> rpcInOut = new ArrayList<>();
ContainerSchemaNode input = rpc.getInput();
ContainerSchemaNode output = rpc.getOutput();
if (input != null) {
rpcInOut.add(new DataNodeIterator(input));
GeneratedTypeBuilder inType = addRawInterfaceDefinition(basePackageName, input, rpcName);
addInterfaceDefinition(input, inType);
resolveDataSchemaNodes(basePackageName, inType, input.getChildNodes());
Type inTypeInstance = inType.toInstance();
genRPCTypes.add(inTypeInstance);
method.addParameter(inTypeInstance, "input");
}
Type outTypeInstance = Types.typeForClass(Void.class);
if (output != null) {
rpcInOut.add(new DataNodeIterator(output));
GeneratedTypeBuilder outType = addRawInterfaceDefinition(basePackageName, output, rpcName);
addInterfaceDefinition(output, outType);
resolveDataSchemaNodes(basePackageName, outType, output.getChildNodes());
outTypeInstance = outType.toInstance();
genRPCTypes.add(outTypeInstance);
}
final Type rpcRes = Types.parameterizedTypeFor(Types.typeForClass(RpcResult.class), outTypeInstance);
method.setReturnType(Types.parameterizedTypeFor(future, rpcRes));
for (DataNodeIterator it : rpcInOut) {
List<ContainerSchemaNode> nContainers = it.allContainers();
if ((nContainers != null) && !nContainers.isEmpty()) {
for (final ContainerSchemaNode container : nContainers) {
if (!container.isAddedByUses()) {
genRPCTypes.add(containerToGenType(basePackageName, container));
}
}
}
List<ListSchemaNode> nLists = it.allLists();
if ((nLists != null) && !nLists.isEmpty()) {
for (final ListSchemaNode list : nLists) {
if (!list.isAddedByUses()) {
genRPCTypes.addAll(listToGenType(basePackageName, list));
}
}
}
}
}
}
genRPCTypes.add(interfaceBuilder.toInstance());
return genRPCTypes;
}