本文整理了Java中org.opendaylight.yangtools.yang.model.api.Module.getIdentities()
方法的一些代码示例,展示了Module.getIdentities()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Module.getIdentities()
方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.model.api.Module
类名称:Module
方法名:getIdentities
[英]Returns IdentitySchemaNode
instances which contain data from identity statements defined in the module.
[中]返回IdentitySchemaNode
实例,其中包含模块中定义的标识语句中的数据。
代码示例来源:origin: opendaylight/yangtools
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));
}
代码示例来源:origin: org.opendaylight.yangtools/yang-data-jaxen
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));
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl
/**
* Converts all <b>identities</b> of the module to the list of
* <code>Type</code> objects.
*
* @param module
* module from which is obtained set of all identity objects to
* iterate over them
* @param schemaContext
* schema context only used as input parameter for method
* {@link BindingGeneratorImpl#identityToGenType}
*
*/
private void allIdentitiesToGenTypes(final ModuleContext context) {
final Set<IdentitySchemaNode> schemaIdentities = context.module().getIdentities();
if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
for (final IdentitySchemaNode identity : schemaIdentities) {
identityToGenType(context, identity);
}
}
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
private static Map<String, Map<Date, IdentityMapping>> transformIdentities(Set<Module> modules) {
Map<String, Map<Date, IdentityMapping>> mappedIds = Maps.newHashMap();
for (Module module : modules) {
String namespace = module.getNamespace().toString();
Map<Date, IdentityMapping> revisionsByNamespace= mappedIds.get(namespace);
if(revisionsByNamespace == null) {
revisionsByNamespace = Maps.newHashMap();
mappedIds.put(namespace, revisionsByNamespace);
}
Date revision = module.getRevision();
IdentityMapping identityMapping = revisionsByNamespace.get(revision);
if(identityMapping == null) {
identityMapping = new IdentityMapping();
revisionsByNamespace.put(revision, identityMapping);
}
for (IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
identityMapping.addIdSchemaNode(identitySchemaNode);
}
}
return mappedIds;
}
代码示例来源:origin: opendaylight/yangtools
@Override
protected final QName createQName(final String prefix, final String localName) {
final Module module = moduleForPrefix(prefix);
checkArgument(module != null, "Failed to lookup prefix %s", prefix);
final QName qname = QName.create(module.getQNameModule(), localName);
for (IdentitySchemaNode identity : module.getIdentities()) {
if (qname.equals(identity.getQName())) {
return identity.getQName();
}
}
throw new IllegalArgumentException("Failed to find identity matching " + qname);
}
}
代码示例来源:origin: org.opendaylight.yangtools/yang-data-util
@Override
protected final QName createQName(final String prefix, final String localName) {
final Module module = moduleForPrefix(prefix);
checkArgument(module != null, "Failed to lookup prefix %s", prefix);
final QName qname = QName.create(module.getQNameModule(), localName);
for (IdentitySchemaNode identity : module.getIdentities()) {
if (qname.equals(identity.getQName())) {
return identity.getQName();
}
}
throw new IllegalArgumentException("Failed to find identity matching " + qname);
}
}
代码示例来源:origin: org.opendaylight.yangtools/yang-data-util
/**
* Parse a string into a QName using specified prefix-to-QNameModule mapping function, interpreting the result
* as an IdentitySchemaNode existing in specified SchemaContext.
*
* @param value string value to parse
* @param schemaContext Parent schema context
* @param prefixToModule prefix-to-QNameModule mapping function
* @return Corresponding IdentitySchemaNode.
* @throws IllegalArgumentException if the value is invalid or does not refer to an existing identity
*/
public static IdentitySchemaNode parseIdentity(final String value, final SchemaContext schemaContext,
final Function<String, QNameModule> prefixToModule) {
final QName qname = QNameCodecUtil.decodeQName(value, prefixToModule);
final Optional<Module> optModule = schemaContext.findModule(qname.getModule());
checkState(optModule.isPresent(), "Parsed QName %s refers to a non-existent module", qname);
for (IdentitySchemaNode identity : optModule.get().getIdentities()) {
if (qname.equals(identity.getQName())) {
return identity;
}
}
throw new IllegalArgumentException("Parsed QName " + qname + " does not refer to a valid identity");
}
}
代码示例来源:origin: opendaylight/yangtools
/**
* Parse a string into a QName using specified prefix-to-QNameModule mapping function, interpreting the result
* as an IdentitySchemaNode existing in specified SchemaContext.
*
* @param value string value to parse
* @param schemaContext Parent schema context
* @param prefixToModule prefix-to-QNameModule mapping function
* @return Corresponding IdentitySchemaNode.
* @throws IllegalArgumentException if the value is invalid or does not refer to an existing identity
*/
public static IdentitySchemaNode parseIdentity(final String value, final SchemaContext schemaContext,
final Function<String, QNameModule> prefixToModule) {
final QName qname = QNameCodecUtil.decodeQName(value, prefixToModule);
final Optional<Module> optModule = schemaContext.findModule(qname.getModule());
checkState(optModule.isPresent(), "Parsed QName %s refers to a non-existent module", qname);
for (IdentitySchemaNode identity : optModule.get().getIdentities()) {
if (qname.equals(identity.getQName())) {
return identity;
}
}
throw new IllegalArgumentException("Parsed QName " + qname + " does not refer to a valid identity");
}
}
代码示例来源:origin: org.opendaylight.yangtools/binding-generator-impl
/**
* Converts all <b>identities</b> of the module to the list of
* <code>Type</code> objects.
*
* @param module
* module from which is obtained set of all identity objects to
* iterate over them
* @param context
* schema context only used as input parameter for method
* {@link identityToGenType}
*
*/
private void allIdentitiesToGenTypes(final Module module, final SchemaContext context) {
final Set<IdentitySchemaNode> schemaIdentities = module.getIdentities();
final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
for (final IdentitySchemaNode identity : schemaIdentities) {
identityToGenType(module, basePackageName, identity, context);
}
}
}
代码示例来源:origin: org.opendaylight.netconf/sal-rest-docgen
Set<IdentitySchemaNode> idNodes = module.getIdentities();
LOG.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size());
代码示例来源:origin: org.opendaylight.controller/yang-jmx-generator
currentModule.getIdentities());
int lastSize = notVisited.size() + 1;
while (!notVisited.isEmpty()) {
代码示例来源:origin: org.opendaylight.controller/yang-jmx-generator
private Map<String, IdentitySchemaNode> getIdentityMap() {
Map<String, IdentitySchemaNode> moduleIdentities = Maps.newHashMap();
for (IdentitySchemaNode id : currentModule.getIdentities()) {
if (id.getBaseIdentity() != null
&& ConfigConstants.MODULE_TYPE_Q_NAME.equals(id.getBaseIdentity().getQName())) {
代码示例来源:origin: org.opendaylight.controller/yang-jmx-generator
Set<QName> allIdentitiesInModule = Sets.newHashSet(Collections2.transform(currentModule.getIdentities(), QNAME_FROM_NODE));
代码示例来源:origin: org.opendaylight.yangtools/binding-generator-impl
final int length = Iterables.size(splittedElement);
if (length == 1) {
identity = findIdentityByName(module.getIdentities(), iterator.next());
basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
} else if (length == 2) {
+ prefix);
identity = findIdentityByName(dependentModule.getIdentities(), iterator.next());
basePackageName = BindingMapping.getRootPackageName(dependentModule.getQNameModule());
} else {
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl
final int length = Iterables.size(splittedElement);
if (length == 1) {
identity = findIdentityByName(module.getIdentities(), iterator.next());
basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
} else if (length == 2) {
+ prefix);
identity = findIdentityByName(dependentModule.getIdentities(), iterator.next());
basePackageName = BindingMapping.getRootPackageName(dependentModule.getQNameModule());
} else {
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl
/**
* 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));
}
代码示例来源:origin: org.opendaylight.yangtools/binding-type-provider
baseIdQName.getRevision());
IdentitySchemaNode identity = null;
for (IdentitySchemaNode id : module.getIdentities()) {
if (id.getQName().equals(baseIdQName)) {
identity = id;
代码示例来源:origin: org.opendaylight.yangtools/yang-model-export
private void emitBodyNodes(final Module input) {
for (final ExtensionDefinition extension : input.getExtensionSchemaNodes()) {
emitExtension(extension);
}
for (final FeatureDefinition definition : input.getFeatures()) {
emitFeature(definition);
}
for (final IdentitySchemaNode identity : input.getIdentities()) {
emitIdentity(identity);
}
for (final Deviation deviation : input.getDeviations()) {
emitDeviation(deviation);
}
emitDataNodeContainer(input);
for (final AugmentationSchemaNode augmentation : input.getAugmentations()) {
emitAugment(augmentation);
}
for (final RpcDefinition rpc : input.getRpcs()) {
emitRpc(rpc);
}
emitNotifications(input.getNotifications());
}
代码示例来源:origin: org.opendaylight.yangtools/binding-generator-impl
Set<IdentitySchemaNode> _identities = module.getIdentities();
boolean _isNullOrEmpty_7 = IterableExtensions.isNullOrEmpty(_identities);
boolean _not_7 = (!_isNullOrEmpty_7);
_builder.newLine();
_builder.append(" ");
Set<IdentitySchemaNode> _identities_1 = module.getIdentities();
CharSequence _writeIdentities = YangTemplate.writeIdentities(_identities_1);
_builder.append(_writeIdentities, " ");
内容来源于网络,如有侵权,请联系作者删除!