@Override public Set<Module> getModules() { final Set<Module> modules = Sets.newHashSet(schemaContext.getModules()); for (final Module module : schemaContext.getModules()) { modules.addAll(module.getSubmodules()); } return modules; }
/** * Returns module instance (from the context) with specified name and no revision. * * @param name string with the module name * @return module instance which has name and revision the same as are the values specified in <code>name</code> * and no revision. * @throws NullPointerException if name is null */ default Optional<Module> findModule(final String name) { return findModule(name, Optional.empty()); }
public NetconfDeviceRpc(final SchemaContext schemaContext, final RemoteDeviceCommunicator<NetconfMessage> listener, final MessageTransformer<NetconfMessage> transformer) { this.listener = listener; this.transformer = transformer; availableRpcs = Collections2.transform(schemaContext.getOperations(), RPC_TO_RPC_IDENTIFIER); }
public NetconfMessageTransformer(final SchemaContext schemaContext, final boolean strictParsing) { this.counter = new MessageCounter(); this.schemaContext = schemaContext; parserFactory = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, schemaContext, strictParsing); mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), QNAME_FUNCTION); mappedNotifications = Multimaps.index(schemaContext.getNotifications(), QNAME_NOREV_FUNCTION); }
private static Optional<DataNodeContainer> findFirstDataNodeContainerInRpcOrAction(final SchemaContext ctx, final Class<? extends TreeNode> targetType) { final YangModuleInfo moduleInfo; try { moduleInfo = BindingReflections.getModuleInfo(targetType); } catch (final Exception e) { throw new IllegalArgumentException( String.format("Failed to load module information for class %s", targetType), e); } Optional<DataNodeContainer> optional = null; optional = findFirst(ctx.getOperations(), moduleInfo, targetType); if (optional.isPresent()) { return optional; } else { return findFirst(ctx.getActions(), moduleInfo, targetType); } }
@Override public boolean apply(final BindingRuntimeContext input) { return input.getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision) != null; } });
@Override public Set<NotificationDefinition> getNotifications() { return getCurrentSchema().getNotifications(); }
if (_equals) { _builder.append(" "); final Set<Module> modules = this.ctx.getModules(); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append(" "); _builder.append("set.add("); Module _findModuleByName = this.ctx.findModuleByName(name, rev); QNameModule _qNameModule_1 = _findModuleByName.getQNameModule(); String _rootPackageName_1 = BindingMapping.getRootPackageName(_qNameModule_1);
@Override protected Module moduleForPrefix(final String prefix) { return context.findModuleByName(prefix, null); }
@Override public DataSchemaNode getDataChildByName(final String s) { return getCurrentSchema().getDataChildByName(s); }
@Override protected String prefixForNamespace(final URI namespace) { final Module module = context.findModuleByNamespaceAndRevision(namespace, null); return module == null ? null : module.getName(); }
private Optional<SchemaNode> tryFindNotification(final SchemaContext ctx, final QName qname) { return Optional.<SchemaNode>fromNullable(Iterables.find(ctx.getNotifications(), new SchemaNodePredicate(qname), null)); }
public Module findModuleByName(final String moduleName) { checkPreconditions(); Preconditions.checkArgument(moduleName != null && !moduleName.isEmpty()); return globalSchema.findModuleByName(moduleName, null); }
/** * Returns operation Input or Output Data container from operation definition. * * @param schema * - SchemaContext in which lookup should be performed * @param path * - Schema path of operation input/output data container * @return operation schema or null, if operation is not present in schema context. */ private ContainerSchemaNode getOperationDataSchema(final SchemaContext schema, 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(); Preconditions.checkArgument(it.hasNext(), "Operation must have QName."); final QName operationName = it.next(); Preconditions.checkArgument(it.hasNext(), "input or output must be part of path."); final QName inOrOut = it.next(); ContainerSchemaNode contSchemaNode = null; if ((contSchemaNode = getOperationDataSchema(schema.getOperations(), operationName, inOrOut)) == null) { contSchemaNode = getOperationDataSchema(schema.getActions(), operationName, inOrOut); } return contSchemaNode; }
@Override public DataSchemaNode getDataChildByName(final QName qName) { return getCurrentSchema().getDataChildByName(qName); }
/** * Generate Types from whole Schema Context. The method will return List of All Generated Types that could be * Generated from Schema Context. * * @param context Schema Context * @return List of Generated Types * * @see SchemaContext */ default List<Type> generateTypes(final SchemaContext context) { return generateTypes(context, context.getModules()); }
@Override public boolean test(final BindingRuntimeContext input) { return input.getSchemaContext().findModule(module).isPresent(); } });
private static RpcDefinition findCreateSubscriptionRpc() { return Iterables.getFirst(Collections2.filter(NOTIFICATIONS_SCHEMA_CTX.getOperations(), new Predicate<RpcDefinition>() { @Override public boolean apply(final RpcDefinition input) { return input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION); } }), null); }
public Module findModuleByNamespace(final DOMMountPoint mountPoint, final URI namespace) { Preconditions.checkArgument(namespace != null && mountPoint != null); final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); if (mountPointSchema == null) { return null; } return mountPointSchema.findModuleByNamespaceAndRevision(namespace, null); }
@Override public List<SchemaPath> getAvailableNotifications() { final List<SchemaPath> availNotifList = new ArrayList<>(); // add Event Source Connection status notification availNotifList.add(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH); final Set<NotificationDefinition> availableNotifications = mount.getSchemaContext() .getNotifications(); // add all known notifications from netconf device for (final NotificationDefinition nd : availableNotifications) { availNotifList.add(nd.getPath()); } return availNotifList; }