private static IdentitySchemaNode findIdentityByName(final Set<IdentitySchemaNode> identities, final String name) { for (final IdentitySchemaNode id : identities) { if (id.getQName().getLocalName().equals(name)) { return id; } } return null; }
private void emitIdentity(final IdentitySchemaNode identity) { super.writer.startIdentityNode(identity.getQName()); emitBaseIdentities(identity.getBaseIdentities()); emitDocumentedNode(identity); super.writer.endNode(); }
public ModuleMXBeanEntryInitialBuilder setIdSchemaNode(IdentitySchemaNode idSchemaNode) { this.localName = idSchemaNode.getQName().getLocalName(); this.description = idSchemaNode.getDescription(); return this; }
/** * Seeks for identity reference <code>idref</code> the JAVA <code>type</code>. * * <p> * <i>Example:<br /> * If identy which is referenced via <code>idref</code> has name <b>Idn</b> * then returning type is <b>{@code Class<? extends Idn>}</b></i> * * @param idref identityref type definition for which JAVA <code>Type</code> is sought * @return JAVA <code>Type</code> of the identity which is referenced through <code>idref</code> */ private Type provideTypeForIdentityref(final IdentityrefTypeDefinition idref) { final Collection<IdentitySchemaNode> identities = idref.getIdentities(); if (identities.size() > 1) { LOG.warn("Identity reference {} has multiple identities, using only the first one", idref); } final QName baseIdQName = identities.iterator().next().getQName(); final Module module = schemaContext.findModule(baseIdQName.getModule()).orElse(null); IdentitySchemaNode identity = null; for (IdentitySchemaNode id : module.getIdentities()) { if (id.getQName().equals(baseIdQName)) { identity = id; } } Preconditions.checkArgument(identity != null, "Target identity '" + baseIdQName + "' do not exists"); final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule()); final JavaTypeName identifier = JavaTypeName.create(BindingGeneratorUtil.packageNameForGeneratedType( basePackageName, identity.getPath()), BindingMapping.getClassName(identity.getQName())); return Types.classType(Types.wildcardTypeFor(identifier)); }
return; final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath()); final String genTypeName = BindingMapping.getClassName(identity.getQName()); final GeneratedTOBuilderImpl newType = new GeneratedTOBuilderImpl(packageName, genTypeName); final IdentitySchemaNode baseIdentity = identity.getBaseIdentity(); if (baseIdentity == null) { final GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(BaseIdentity.class.getPackage().getName(), final String returnTypePkgName = BindingMapping.getRootPackageName(baseIdentityParentModule .getQNameModule()); final String returnTypeName = BindingMapping.getClassName(baseIdentity.getQName()); final GeneratedTransferObject gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName) .toInstance(); newType.addComment(identity.getDescription()); newType.setDescription(createDescription(identity, newType.getFullyQualifiedName())); newType.setReference(identity.getReference()); newType.setModuleName(module.getName()); newType.setSchemaPath(identity.getPath().getPathFromRoot()); final QName qname = identity.getQName(); qnameConstant(newType, BindingMapping.QNAME_STATIC_FIELD_NAME, qname); genCtx.get(module).addIdentityType(identity.getQName(), newType);
String identityName = idNode.getQName().getLocalName(); LOG.debug("Processing Identity: {}", identityName); identityObj.put(DESCRIPTION_KEY, idNode.getDescription()); IdentitySchemaNode baseId = idNode.getBaseIdentity(); Set<IdentitySchemaNode> derivedIds = idNode.getDerivedIdentities(); subTypes.put(derivedId.getQName().getLocalName()); props.put(TYPE_KEY, baseId.getQName().getLocalName());
QName _qName = identity.getQName(); String _localName = _qName.getLocalName(); _builder.append(_localName, ""); IdentitySchemaNode _baseIdentity = identity.getBaseIdentity(); boolean _notEquals = (!Objects.equal(_baseIdentity, null)); if (_notEquals) { _builder.append(" "); _builder.append("base \"("); IdentitySchemaNode _baseIdentity_1 = identity.getBaseIdentity(); String _writeIdentityNs = YangTemplate.writeIdentityNs(_baseIdentity_1); _builder.append(_writeIdentityNs, " "); _builder.append(")"); IdentitySchemaNode _baseIdentity_2 = identity.getBaseIdentity(); _builder.append(_baseIdentity_2, " "); _builder.append("\";"); String _description = identity.getDescription(); boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_description); boolean _not = (!_isNullOrEmpty); _builder.append(" "); _builder.append("\""); String _description_1 = identity.getDescription(); _builder.append(_description_1, " "); _builder.append("\";"); String _reference = identity.getReference(); boolean _isNullOrEmpty_1 = StringExtensions.isNullOrEmpty(_reference);
name = JavaTypeName.create(packageNameForGeneratedType(context.modulePackageName(), identity.getPath()), BindingMapping.getClassName(identity.getQName())); final Set<IdentitySchemaNode> baseIdentities = identity.getBaseIdentities(); if (!baseIdentities.isEmpty()) { for (IdentitySchemaNode baseIdentity : baseIdentities) { JavaTypeName base = renames.get(baseIdentity); if (base == null) { final QName qname = baseIdentity.getQName(); base = JavaTypeName.create(BindingMapping.getRootPackageName(qname.getModule()), BindingMapping.getClassName(qname)); addCodegenInformation(newType, module, identity); newType.setModuleName(module.getName()); newType.setSchemaPath(identity.getPath()); identity.getQName().getLocalName());
if (id.getBaseIdentity() != null && ConfigConstants.MODULE_TYPE_Q_NAME.equals(id.getBaseIdentity().getQName())) { String identityLocalName = id.getQName().getLocalName(); if (moduleIdentities.containsKey(identityLocalName)) { throw new IllegalStateException("Module name already defined in this currentModule: " for (UnknownSchemaNode unknownNode : id.getUnknownSchemaNodes()) {
checkNotNull(base); this.maybeBaseCache = base; List<UnknownSchemaNode> unknownSchemaNodes = id.getUnknownSchemaNodes(); List<String> exportedOsgiClassNames = new ArrayList<>( unknownSchemaNodes.size()); qName = id.getQName(); nullableDescription = id.getDescription(); typeName = getSimpleName(exportedOsgiClassName) + CLASS_NAME_SUFFIX; this.packageName = packageName;
IdentitySchemaNode identity = iterator.next(); ServiceInterfaceEntry created = null; if (identity.getBaseIdentity() == null) { } else if (identity.getBaseIdentity().getQName() .equals(SERVICE_TYPE_Q_NAME)) { } else { ServiceInterfaceEntry foundBase = definedSEItracker .get(identity.getBaseIdentity()); created.setYangModuleName(currentModule.getName()); created.setYangModuleLocalname(identity.getQName() .getLocalName()); identitiesToSIs.put(identity, created);
private static boolean isAncestorOf(final IdentitySchemaNode identity, final IdentitySchemaNode descendant) { for (IdentitySchemaNode base : descendant.getBaseIdentities()) { if (identity.equals(base) || isAncestorOf(identity, base)) { return true; } } return false; }
QName baseIdQName = idref.getIdentity().getQName(); Module module = schemaContext.findModuleByNamespaceAndRevision(baseIdQName.getNamespace(), baseIdQName.getRevision()); IdentitySchemaNode identity = null; for (IdentitySchemaNode id : module.getIdentities()) { if (id.getQName().equals(baseIdQName)) { identity = id; final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath()); final String genTypeName = BindingMapping.getClassName(identity.getQName());
private static boolean isAncestorOf(final IdentitySchemaNode identity, final IdentitySchemaNode descendant) { for (IdentitySchemaNode base : descendant.getBaseIdentities()) { if (identity.equals(base) || isAncestorOf(identity, base)) { return true; } } return false; }
void addIdSchemaNode(IdentitySchemaNode node) { String name = node.getQName().getLocalName(); Preconditions.checkState(!identityNameToSchemaNode.containsKey(name)); identityNameToSchemaNode.put(name, node); }
final AnnotationTypeBuilder rc = getter.addAnnotation(clazz.getPackage().getName(), clazz.getSimpleName()); final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath()); final String genTypeName = BindingMapping.getClassName(identity.getQName().getLocalName()); rc.addParameter("value", packageName + "." + genTypeName + ".class");
private void emitBaseIdentities(final Set<IdentitySchemaNode> identities) { for (final IdentitySchemaNode identitySchemaNode : identities) { emitBase(identitySchemaNode.getQName()); } }
private IdentitySchemaNode findIdentityByName(final Set<IdentitySchemaNode> identities, final String name) { for (final IdentitySchemaNode id : identities) { if (id.getQName().getLocalName().equals(name)) { return id; } } return null; }
private static IdentitySchemaNode findIdentitySchemaNodeInModule(final Module module, final QName identityQName) { for (final IdentitySchemaNode id : module.getIdentities()) { if (identityQName.equals(id.getQName())) { return id; } } throw new IllegalArgumentException(String.format("Identity %s does not have a corresponding" + " identity schema node in the module %s.", identityQName, module)); }