private final QName argument;
private final boolean yinElement;
- private Rfc6020Mapping(Class<? extends DeclaredStatement<?>> clz, final String nameStr) {
+ Rfc6020Mapping(Class<? extends DeclaredStatement<?>> clz, final String nameStr) {
type = Preconditions.checkNotNull(clz);
name = yinQName(nameStr);
argument = null;
yinElement = false;
}
- private Rfc6020Mapping(Class<? extends DeclaredStatement<?>> clz, final String nameStr, final String argumentStr) {
+ Rfc6020Mapping(Class<? extends DeclaredStatement<?>> clz, final String nameStr, final String argumentStr) {
type = Preconditions.checkNotNull(clz);
name = yinQName(nameStr);
argument = yinQName(argumentStr);
this.yinElement = false;
}
- private Rfc6020Mapping(Class<? extends DeclaredStatement<?>> clz, final String nameStr, final String argumentStr,
+ Rfc6020Mapping(Class<? extends DeclaredStatement<?>> clz, final String nameStr, final String argumentStr,
final boolean yinElement) {
type = Preconditions.checkNotNull(clz);
name = yinQName(nameStr);
@Rfc6020AbnfRule("leafref-specification")
interface LeafrefSpecification extends TypeStatement {
- @Nullable PathStatement getPath();
+ @Nonnull PathStatement getPath();
}
+ @Rfc6020AbnfRule("instanceidentifier-specification")
interface InstanceIdentifierSpecification extends TypeStatement {
@Nullable RequireInstanceStatement getRequireInstance();
}
-
+ @Rfc6020AbnfRule("identityref-specification")
interface IdentityRefSpecification extends TypeStatement {
+ @Nonnull BaseStatement getBase();
+
}
+
+ @Rfc6020AbnfRule("bits-specification")
interface BitsSpecification extends TypeStatement {
@Nonnull Collection<? extends BitStatement> getBits();
}
+ @Rfc6020AbnfRule("union-specification")
interface UnionSpecification extends TypeStatement {
@Nonnull Collection<? extends TypeStatement> getTypes();
}
+
+ @Rfc6020AbnfRule("binary-specification")
+ interface BinarySpecification extends TypeStatement {
+
+ @Nullable LengthStatement getLength();
+ }
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.antlr.v4.runtime.tree.ParseTree;
import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParserBaseListener;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import javax.annotation.concurrent.Immutable;
private QNameToStatementDefinition stmtDef;
private PrefixToModule prefixes;
private List<String> toBeSkipped = new ArrayList<>();
+ private boolean isType = false;
private static final Logger LOG = LoggerFactory.getLogger(YangStatementParserListenerImpl.class);
public YangStatementParserListenerImpl(StatementSourceReference ref) {
this.prefixes = prefixes;
}
+ private static boolean hasNotEmptyBody(List<ParseTree> children) {
+ for (ParseTree child : children) {
+ if (child instanceof YangStatementParser.StatementContext) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public void enterStatement(YangStatementParser.StatementContext ctx) {
boolean action = true;
+ QName identifier;
for (int i = 0; i < ctx.getChildCount(); i++) {
ParseTree child = ctx.getChild(i);
if (child instanceof YangStatementParser.KeywordContext) {
try {
- QName identifier = new QName(YangConstants.RFC6020_YIN_NAMESPACE,
+ identifier = new QName(YangConstants.RFC6020_YIN_NAMESPACE,
((YangStatementParser.KeywordContext) child).children.get(0).getText());
if (stmtDef != null && Utils.isValidStatementDefinition(prefixes, stmtDef, identifier) && toBeSkipped.isEmpty()) {
- writer.startStatement(identifier, ref);
+ if (identifier.equals(Rfc6020Mapping.TYPE.getStatementName()) && hasNotEmptyBody(((YangStatementParser.KeywordContext) child).getParent().children)) {
+ isType = true;
+ } else {
+ writer.startStatement(identifier, ref);
+ }
} else {
action = false;
toBeSkipped.add(((YangStatementParser.KeywordContext) child).children.get(0).getText());
}
} else if (child instanceof YangStatementParser.ArgumentContext) {
try {
- if (action) {
- writer.argumentValue(
- Utils.stringFromStringContext((YangStatementParser.ArgumentContext) child), ref);
+ final String argument = Utils.stringFromStringContext((YangStatementParser.ArgumentContext) child);
+ if (isType) {
+ writer.startStatement(new QName(YangConstants.RFC6020_YIN_NAMESPACE, argument), ref);
+ writer.argumentValue(argument, ref);
+ isType = false;
+ } else if (action) {
+ writer.argumentValue(Utils.stringFromStringContext((YangStatementParser.ArgumentContext) child), ref);
} else {
action = true;
}
package org.opendaylight.yangtools.yang.parser.spi;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
/**
*
* identity identifier namespace.
*
*/
-public interface IdentityNamespace extends IdentifierNamespace<QName, IdentityStatement> {
+public interface IdentityNamespace extends IdentifierNamespace<QName, StmtContext.Mutable<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>>> {
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.YangConstants;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Objects;
-import javax.annotation.Nullable;
import org.opendaylight.yangtools.concepts.Mutable;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.util.BaseTypes;
import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.ContextBuilder;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.BitsSpecificationImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Decimal64SpecificationImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.EnumSpecificationImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.IdentityRefSpecificationImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.InstanceIdentifierSpecificationImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.LeafrefSpecificationImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.NumericalRestrictionsImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.StringRestrictionsImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.UnionSpecificationImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.UnknownStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+
public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBehaviour.Registry, Mutable {
public enum PhaseCompletionProgress {
ContextBuilder<?, ?, ?> createDeclaredChild(StatementContextBase<?, ?, ?> current, QName name, StatementSourceReference ref) {
StatementDefinitionContext<?,?,?> def = getDefinition(name);
- //extensions
- if (def == null) {
+ if (def == null && BaseTypes.isYangBuildInType(name.getLocalName())) {
+ //type-body-stmts
+ def = resolveTypeBodyStmts(name.getLocalName());
+ } else if (def == null) {
+ //extensions
if (Utils.isValidStatementDefinition(prefixToModuleMap, qNameToStmtDefMap, name)) {
def = new StatementDefinitionContext<>(new UnknownStatementImpl.Definition(qNameToStmtDefMap.get(Utils.trimPrefix(name))));
}
}
}
+ private StatementDefinitionContext<?,?,?> resolveTypeBodyStmts(String typeArgument) {
+ switch (typeArgument) {
+ case "int8": case "int16": case "int32": case "int64": case "uint8": case "uint16": case "uint32": case "uint64":
+ return new StatementDefinitionContext<>(new NumericalRestrictionsImpl.Definition());
+ case "decimal64":
+ return new StatementDefinitionContext<>(new Decimal64SpecificationImpl.Definition());
+ case "union":
+ return new StatementDefinitionContext<>(new UnionSpecificationImpl.Definition());
+ case "string":
+ return new StatementDefinitionContext<>(new StringRestrictionsImpl.Definition());
+ case "enumeration":
+ return new StatementDefinitionContext<>(new EnumSpecificationImpl.Definition());
+ case "leafref":
+ return new StatementDefinitionContext<>(new LeafrefSpecificationImpl.Definition());
+ case "bits":
+ return new StatementDefinitionContext<>(new BitsSpecificationImpl.Definition());
+ case "identityref":
+ return new StatementDefinitionContext<>(new IdentityRefSpecificationImpl.Definition());
+ case "instance-identifier":
+ return new StatementDefinitionContext<>(new InstanceIdentifierSpecificationImpl.Definition());
+ default:
+ return null;
+ }
+ }
+
+
private PrefixToModule prefixes() {
Map<String, QNameModule> prefixes = (Map<String, QNameModule>) currentContext.getAllFromNamespace(PrefixToModule.class);
for (Map.Entry<String, QNameModule> prefix : prefixes.entrySet()) {
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public class BinarySpecificationImpl extends AbstractDeclaredStatement<String> implements TypeStatement.BinarySpecification {
+
+ protected BinarySpecificationImpl(StmtContext<String, ?, ?> context) {
+ super(context);
+ }
+
+ public static class Definition extends AbstractStatementSupport<String, BinarySpecification, EffectiveStatement<String, BinarySpecification>> {
+
+ public Definition() {
+ super(Rfc6020Mapping.TYPE);
+ }
+
+ @Override
+ public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+ return value;
+ }
+
+ @Override
+ public BinarySpecification createDeclared(StmtContext<String, BinarySpecification, ?> ctx) {
+ return new BinarySpecificationImpl(ctx);
+ }
+
+ @Override
+ public EffectiveStatement<String, BinarySpecification> createEffective(StmtContext<String, BinarySpecification, EffectiveStatement<String, BinarySpecification>> ctx) {
+ return null;
+ }
+ }
+
+ @Nullable
+ @Override
+ public LengthStatement getLength() {
+ return firstDeclared(LengthStatement.class);
+ }
+
+ @Nonnull
+ @Override
+ public String getName() {
+ return argument();
+ }
+}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
super(context);
}
- public static class Definition
- extends
- AbstractStatementSupport<String, BitStatement, EffectiveStatement<String, BitStatement>> {
+ public static class Definition extends AbstractStatementSupport<String, BitStatement, EffectiveStatement<String, BitStatement>> {
public Definition() {
super(Rfc6020Mapping.BIT);
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BitsSpecificationEffectiveStatementImpl;
public class BitsSpecificationImpl extends AbstractDeclaredStatement<String>
implements TypeStatement.BitsSpecification {
@Override
public EffectiveStatement<String, TypeStatement.BitsSpecification> createEffective(
StmtContext<String, TypeStatement.BitsSpecification, EffectiveStatement<String, TypeStatement.BitsSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ return new BitsSpecificationEffectiveStatementImpl(ctx);
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
import org.opendaylight.yangtools.yang.model.api.stmt.FractionDigitsStatement;
-
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.Decimal64SpecificationEffectiveStatementImpl;
public class Decimal64SpecificationImpl extends AbstractDeclaredStatement<String> implements TypeStatement.Decimal64Specification{
public static class Definition extends AbstractStatementSupport<String,TypeStatement.Decimal64Specification,EffectiveStatement<String,TypeStatement.Decimal64Specification>> {
public Definition() {
- super(Rfc6020Mapping.FRACTION_DIGITS);
+ super(Rfc6020Mapping.TYPE);
}
@Override public String parseArgumentValue(StmtContext<?, ?, ?> ctx,
@Override public EffectiveStatement<String, TypeStatement.Decimal64Specification> createEffective(
StmtContext<String, TypeStatement.Decimal64Specification, EffectiveStatement<String, TypeStatement.Decimal64Specification>> ctx) {
- throw new UnsupportedOperationException();
+ return new Decimal64SpecificationEffectiveStatementImpl(ctx);
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EnumSpecificationEffectiveStatementImpl;
public class EnumSpecificationImpl extends AbstractDeclaredStatement<String>
implements TypeStatement.EnumSpecification {
AbstractStatementSupport<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> {
public Definition() {
- super(Rfc6020Mapping.ENUM);
+ super(Rfc6020Mapping.TYPE);
}
@Override
@Override
public EffectiveStatement<String, TypeStatement.EnumSpecification> createEffective(
StmtContext<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ return new EnumSpecificationEffectiveStatementImpl(ctx);
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
}
@Override
- public void onStatementDefinitionDeclared(final StmtContext.Mutable<QName, ExtensionStatement, EffectiveStatement<QName, ExtensionStatement>> stmt) throws InferenceException, SourceException {
+ public void onStatementDefinitionDeclared(final StmtContext.Mutable<QName, ExtensionStatement, EffectiveStatement<QName, ExtensionStatement>> stmt) throws SourceException {
stmt.addContext(ExtensionNamespace.class, stmt.getStatementArgument(), stmt);
}
}
}
@Override
- public void onFullDefinitionDeclared(
- Mutable<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> stmt) throws SourceException {
- stmt.getParentContext().addContext(GroupingNamespace.class, stmt.getStatementArgument(),stmt);
+ public void onFullDefinitionDeclared(Mutable<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> stmt) throws SourceException {
+ if (stmt != null && stmt.getParentContext() != null) {
+ stmt.getParentContext().addContext(GroupingNamespace.class, stmt.getStatementArgument(), stmt);
+ }
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import com.google.common.base.Preconditions;
+import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
+import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IdentityRefSpecificationEffectiveStatementImpl;
-public class IdentityRefSpecificationImpl extends
- AbstractDeclaredStatement<String> implements
- TypeStatement.IdentityRefSpecification {
+import javax.annotation.Nonnull;
+import java.util.Map;
+
+public class IdentityRefSpecificationImpl extends AbstractDeclaredStatement<String> implements TypeStatement.IdentityRefSpecification {
protected IdentityRefSpecificationImpl(
StmtContext<String, TypeStatement.IdentityRefSpecification, ?> context) {
AbstractStatementSupport<String, TypeStatement.IdentityRefSpecification, EffectiveStatement<String, TypeStatement.IdentityRefSpecification>> {
public Definition() {
- super(Rfc6020Mapping.BASE);
+ super(Rfc6020Mapping.TYPE);
}
@Override
@Override
public EffectiveStatement<String, TypeStatement.IdentityRefSpecification> createEffective(
StmtContext<String, TypeStatement.IdentityRefSpecification, EffectiveStatement<String, TypeStatement.IdentityRefSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ return new IdentityRefSpecificationEffectiveStatementImpl(ctx);
+ }
+
+ @Override
+ public void onFullDefinitionDeclared(StmtContext.Mutable<String, IdentityRefSpecification, EffectiveStatement<String, IdentityRefSpecification>> stmt) throws SourceException {
+ //FIXME:
+// StatementContextBase<?, ?, ?> stmtCtx = (StatementContextBase<?, ?, ?>) stmt.getFromNamespace(IdentityNamespace.class, Utils.qNameFromArgument(StmtContextUtils.findFirstDeclaredSubstatement(stmt, BaseStatement.class), (String) StmtContextUtils.findFirstDeclaredSubstatement(stmt, BaseStatement.class).getStatementArgument()));
+// Preconditions.checkArgument(stmtCtx != null, "Identity '%s' doesn't exist in given scope (module, imported submodules)", stmt.getStatementArgument());
}
}
return argument();
}
+ @Nonnull
+ @Override
+ public BaseStatement getBase() {
+ return firstDeclared(BaseStatement.class);
+ }
+
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IdentityEffectiveStatementImpl;
-
import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
super(context);
}
- public static class Definition
- extends
- AbstractStatementSupport<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> {
+ public static class Definition extends AbstractStatementSupport<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> {
public Definition() {
super(Rfc6020Mapping.IDENTITY);
return new IdentityEffectiveStatementImpl(ctx);
}
+ @Override
+ public void onStatementDefinitionDeclared(final StmtContext.Mutable<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> stmt) throws SourceException {
+ stmt.addToNs(IdentityNamespace.class, stmt.getStatementArgument(), stmt);
+ }
}
@Override
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.InstanceIdentifierSpecificationEffectiveStatementImpl;
public class InstanceIdentifierSpecificationImpl extends
AbstractDeclaredStatement<String> implements
AbstractStatementSupport<String, TypeStatement.InstanceIdentifierSpecification, EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification>> {
public Definition() {
- super(Rfc6020Mapping.REQUIRE_INSTANCE);
+ super(Rfc6020Mapping.TYPE);
}
@Override
@Override
public EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification> createEffective(
StmtContext<String, TypeStatement.InstanceIdentifierSpecification, EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ return new InstanceIdentifierSpecificationEffectiveStatementImpl(ctx);
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
import org.opendaylight.yangtools.yang.model.api.stmt.PathStatement;
-
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LeafrefSpecificationEffectiveStatementImpl;
public class LeafrefSpecificationImpl extends AbstractDeclaredStatement<String>
implements TypeStatement.LeafrefSpecification {
AbstractStatementSupport<String, TypeStatement.LeafrefSpecification, EffectiveStatement<String, TypeStatement.LeafrefSpecification>> {
public Definition() {
- super(Rfc6020Mapping.PATH);
+ super(Rfc6020Mapping.TYPE);
}
@Override
@Override
public EffectiveStatement<String, TypeStatement.LeafrefSpecification> createEffective(
StmtContext<String, TypeStatement.LeafrefSpecification, EffectiveStatement<String, TypeStatement.LeafrefSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ return new LeafrefSpecificationEffectiveStatementImpl(ctx);
}
}
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MustEffectiveStatementImpl;
@Override public RevisionAwareXPath parseArgumentValue(
StmtContext<?, ?, ?> ctx, String value) throws SourceException {
- return new RevisionAwareXPathImpl(value, false);
+ return new RevisionAwareXPathImpl(value, Utils.isXPathAbsolute(value));
}
@Override public MustStatement createDeclared(
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.NumericalRestrictionsEffectiveStatementImpl;
public class NumericalRestrictionsImpl extends AbstractDeclaredStatement<String> implements TypeStatement.NumericalRestrictions{
public static class Definition extends AbstractStatementSupport<String,TypeStatement.NumericalRestrictions,EffectiveStatement<String,TypeStatement.NumericalRestrictions>> {
public Definition() {
- super(Rfc6020Mapping.RANGE);
+ super(Rfc6020Mapping.TYPE);
}
@Override public String parseArgumentValue(StmtContext<?, ?, ?> ctx,
@Override public EffectiveStatement<String, TypeStatement.NumericalRestrictions> createEffective(
StmtContext<String, TypeStatement.NumericalRestrictions, EffectiveStatement<String, TypeStatement.NumericalRestrictions>> ctx) {
- throw new UnsupportedOperationException();
+ return new NumericalRestrictionsEffectiveStatementImpl(ctx);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PathStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MustEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PathEffectiveStatementImpl;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public class PathStatementImpl extends AbstractDeclaredStatement<RevisionAwareXPath> implements
+ PathStatement {
+
+ protected PathStatementImpl(StmtContext<RevisionAwareXPath, PathStatement, ?> context) {
+ super(context);
+ }
+
+ public static class Definition extends AbstractStatementSupport<RevisionAwareXPath,PathStatement,EffectiveStatement<RevisionAwareXPath,PathStatement>> {
+
+ public Definition() {
+ super(Rfc6020Mapping.PATH);
+ }
+
+ @Override public RevisionAwareXPath parseArgumentValue(
+ StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+ return new RevisionAwareXPathImpl(value, Utils.isXPathAbsolute(value));
+ }
+
+ @Override public PathStatement createDeclared(
+ StmtContext<RevisionAwareXPath, PathStatement, ?> ctx) {
+ return new PathStatementImpl(ctx);
+ }
+
+ @Override public EffectiveStatement<RevisionAwareXPath, PathStatement> createEffective(
+ StmtContext<RevisionAwareXPath, PathStatement, EffectiveStatement<RevisionAwareXPath, PathStatement>> ctx) {
+ return new PathEffectiveStatementImpl(ctx);
+ }
+ }
+
+ @Nonnull
+ @Override
+ public String getValue() {
+ return rawArgument();
+ }
+
+}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StringRestrictionsEffectiveStatementImpl;
public class StringRestrictionsImpl extends AbstractDeclaredStatement<String>
implements TypeStatement.StringRestrictions {
@Override
public EffectiveStatement<String, TypeStatement.StringRestrictions> createEffective(
StmtContext<String, TypeStatement.StringRestrictions, EffectiveStatement<String, TypeStatement.StringRestrictions>> ctx) {
- throw new UnsupportedOperationException();
+ return new StringRestrictionsEffectiveStatementImpl(ctx);
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import com.google.common.base.Preconditions;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.model.util.BaseTypes;
+import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.TypeEffectiveStatementImpl;
import javax.annotation.Nonnull;
@Override public EffectiveStatement<String, TypeStatement> createEffective(
StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new TypeEffectiveStatementImpl(ctx);
+ }
+
+ @Override
+ public void onFullDefinitionDeclared(StmtContext.Mutable<String, TypeStatement, EffectiveStatement<String, TypeStatement>> stmt) throws SourceException {
+ if (!BaseTypes.isYangBuildInType(stmt.getStatementArgument())) {
+ if (stmt.getParentContext() != null) {
+ StatementContextBase<?, ?, ?> stmtCtx = (StatementContextBase<?, ?, ?>) stmt.getParentContext().getFromNamespace(TypeNamespace.class, Utils.qNameFromArgument(stmt, stmt.getStatementArgument()));
+ Preconditions.checkArgument(stmtCtx != null, "Typedef '%s' doesn't exist in given scope", stmt.getStatementArgument());
+ }
+ }
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.TypeDefEffectiveStatementImpl;
+
import javax.annotation.Nullable;
public class TypedefStatementImpl extends AbstractDeclaredStatement<QName>
@Override
public EffectiveStatement<QName, TypedefStatement> createEffective(
StmtContext<QName, TypedefStatement, EffectiveStatement<QName, TypedefStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new TypeDefEffectiveStatementImpl(ctx);
+ }
+
+ @Override
+ public void onStatementDefinitionDeclared(StmtContext.Mutable<QName, TypedefStatement, EffectiveStatement<QName, TypedefStatement>> stmt) throws SourceException {
+ if (stmt != null && stmt.getParentContext() != null) {
+ stmt.getParentContext().addContext(TypeNamespace.class, stmt.getStatementArgument(), stmt);
+ }
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
import java.util.Collection;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnionSpecificationEffectiveStatementImpl;
public class UnionSpecificationImpl extends AbstractDeclaredStatement<String>
implements TypeStatement.UnionSpecification {
super(context);
}
- public static class Definition
- extends
- AbstractStatementSupport<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> {
+ public static class Definition extends AbstractStatementSupport<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> {
public Definition() {
super(Rfc6020Mapping.TYPE);
@Override
public EffectiveStatement<String, TypeStatement.UnionSpecification> createEffective(
StmtContext<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ return new UnionSpecificationEffectiveStatementImpl(ctx);
}
}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
@Override public RevisionAwareXPath parseArgumentValue(
StmtContext<?, ?, ?> ctx, String value) throws SourceException {
- return new RevisionAwareXPathImpl(value, false);
+ return new RevisionAwareXPathImpl(value, Utils.isXPathAbsolute(value));
}
@Override public WhenStatement createDeclared(
import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.treeScoped;
import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
-import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
public final class YangInferencePipeline {
.addSupport(sourceLocal(IncludedModuleContext.class))
.addSupport(sourceLocal(ImpPrefixToModuleIdentifier.class))
.addSupport(sourceLocal(BelongsToPrefixToModuleName.class))
- .addSupport(sourceLocal(QNameToStatementDefinition.class))
.build();
private static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle.
.addSupport(new ArgumentStatementImpl.Definition())
.addSupport(new ExtensionStatementImpl.Definition())
.addSupport(global(ExtensionNamespace.class))
+ .addSupport(new TypedefStatementImpl.Definition())
+ .addSupport(treeScoped(TypeNamespace.class))
+ .addSupport(new IdentityStatementImpl.Definition())
+ .addSupport(global(IdentityNamespace.class))
.build();
private static final StatementSupportBundle FULL_DECL_BUNDLE = StatementSupportBundle.
.addSupport(new DefaultStatementImpl.Definition())
.addSupport(new MustStatementImpl.Definition())
.addSupport(new MandatoryStatementImpl.Definition())
- .addSupport(new TypedefStatementImpl.Definition())
.addSupport(new AnyxmlStatementImpl.Definition())
.addSupport(new IfFeatureStatementImpl.Definition())
.addSupport(new UsesStatementImpl.Definition())
.addSupport(new WhenStatementImpl.Definition())
.addSupport(new AugmentStatementImpl.Definition())
.addSupport(new RefineStatementImpl.Definition())
- .addSupport(new IdentityStatementImpl.Definition())
.addSupport(new BaseStatementImpl.Definition())
.addSupport(new FractionDigitsStatementImpl.Definition())
.addSupport(new EnumStatementImpl.Definition())
.addSupport(new ValueStatementImpl.Definition())
.addSupport(new UnitsStatementImpl.Definition())
.addSupport(new RequireInstanceStatementImpl.Definition())
- //TODO: add mapping to Rfc6020Mapping class and uncomment following. Please test it.
-// .addSupport(new EnumSpecificationImpl.Definition())
-// .addSupport(new Decimal64SpecificationImpl.Definition())
-// .addSupport(new IdentityRefSpecificationImpl.Definition())
-// .addSupport(new InstanceIdentifierSpecificationImpl.Definition())
-// .addSupport(new LeafrefSpecificationImpl.Definition())
-// .addSupport(new NumericalRestrictionsImpl.Definition())
-// .addSupport(new StringRestrictionsImpl.Definition())
-// .addSupport(new UnionSpecificationImpl.Definition())
-// .addSupport(new BitStatementImpl.Definition())
+ .addSupport(new BitStatementImpl.Definition())
+ .addSupport(new PathStatementImpl.Definition())
.build();
public static final Map<ModelProcessingPhase, StatementSupportBundle> RFC6020_BUNDLES = ImmutableMap
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BitsSpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.BitsSpecification> {
+
+ public BitsSpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.BitsSpecification, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class Decimal64SpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.Decimal64Specification> {
+
+ public Decimal64SpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.Decimal64Specification, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class EnumSpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.EnumSpecification> {
+
+ public EnumSpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.EnumSpecification, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class IdentityRefSpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.IdentityRefSpecification> {
+
+ public IdentityRefSpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.IdentityRefSpecification, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class InstanceIdentifierSpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.InstanceIdentifierSpecification> {
+
+ public InstanceIdentifierSpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.InstanceIdentifierSpecification, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class LeafrefSpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.LeafrefSpecification> {
+
+ public LeafrefSpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.LeafrefSpecification, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class NumericalRestrictionsEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.NumericalRestrictions> {
+
+ public NumericalRestrictionsEffectiveStatementImpl(StmtContext<String, TypeStatement.NumericalRestrictions, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.PathStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PathEffectiveStatementImpl extends
+ EffectiveStatementBase<RevisionAwareXPath, PathStatement> {
+
+ public PathEffectiveStatementImpl(
+ StmtContext<RevisionAwareXPath, PathStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class StringRestrictionsEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.StringRestrictions> {
+
+ public StringRestrictionsEffectiveStatementImpl(StmtContext<String, TypeStatement.StringRestrictions, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class TypeDefEffectiveStatementImpl extends EffectiveStatementBase<QName, TypedefStatement> {
+
+ public TypeDefEffectiveStatementImpl(StmtContext<QName, TypedefStatement, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class TypeEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement> {
+
+ public TypeEffectiveStatementImpl(StmtContext<String, TypeStatement, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class UnionSpecificationEffectiveStatementImpl extends EffectiveStatementBase<String, TypeStatement.UnionSpecification> {
+
+ public UnionSpecificationEffectiveStatementImpl(StmtContext<String, TypeStatement.UnionSpecification, ?> ctx) {
+ super(ctx);
+ }
+}
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+
+import static org.junit.Assert.assertNotNull;
+
+public class YangTypesStmtTest {
+
+ private static final YangStatementSourceImpl TYPEFILE1 = new YangStatementSourceImpl("/semantic-statement-parser/types.yang");
+ private static final YangStatementSourceImpl TYPEFILE2 = new YangStatementSourceImpl("/semantic-statement-parser/simple-types.yang");
+
+ @Test
+ public void readAndParseYangFileTest() throws SourceException, ReactorException {
+ CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+ addSources(reactor, TYPEFILE1, TYPEFILE2);
+ EffectiveModelContext result = reactor.build();
+ assertNotNull(result);
+ }
+
+ private void addSources(CrossSourceStatementReactor.BuildAction reactor, StatementStreamSource... sources) {
+ for (StatementStreamSource source : sources) {
+ reactor.addSource(source);
+ }
+ }
+}
--- /dev/null
+module simple-types {
+
+ yang-version 1;
+ namespace "urn:simple.types";
+ prefix "st";
+
+ organization "opendaylight";
+ contact "WILL-BE-DEFINED-LATER";
+ revision 2015-04-16;
+
+ typedef myint8 {
+ type int8 {
+ range "1..20";
+ }
+ }
+
+ identity my-base;
+
+ typedef myint32 {
+ type int32 {
+ range "1..2000";
+ }
+ }
+
+ container mycontainer {
+ leaf mynumerical {
+ type int32 {
+ range "1..3000";
+ }
+ }
+
+ leaf mynorestrictions {
+ type string;
+ }
+
+ leaf mytypedefuse1 {
+ type myint32;
+ }
+
+ leaf mytypedefuse2 {
+ type myint8;
+ }
+
+ leaf myunion {
+ type union {
+ type int8;
+ type int32;
+ }
+ }
+
+ leaf mydecimal64 {
+ type decimal64 {
+ fraction-digits 2;
+ range "1 .. 3.14 | 10 | 20..max";
+ }
+ }
+
+ leaf mystring {
+ type string {
+ length "1..255";
+ pattern "[0-9a-fA-F]*";
+ }
+ }
+
+ leaf myenum {
+ type enumeration {
+ enum zero;
+ enum one;
+ enum seven {
+ value 7;
+ }
+ }
+ }
+
+ leaf mybits {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit 10-Mb-only {
+ position 2;
+ }
+ }
+ default "auto-sense-speed";
+ }
+
+ leaf mgmt-interface {
+ type leafref {
+ path "../myenum";
+ }
+ }
+
+ leaf crypto {
+ type identityref {
+ base "my-base";
+ }
+ }
+
+ }
+}
--- /dev/null
+module custom-types-test {
+
+ yang-version 1;
+ namespace "urn:custom.types.demo";
+ prefix "iit";
+
+ organization "opendaylight";
+ contact "WILL-BE-DEFINED-LATER";
+ revision 2012-04-16 {
+ }
+
+ extension mountpoint {
+ description "enter point";
+ argument "name" {
+ yin-element "true";
+ }
+ }
+
+ typedef access-operations-type {
+ type bits {
+ bit create {
+ description "Any protocol operation that creates a new data node.";
+ }
+ bit read {
+ description "Any protocol operation or notification that returns the value of a data node.";
+ position 500;
+ }
+ bit update {
+ description "Any protocol operation that alters an existing data node.";
+ }
+ bit delete {
+ description "Any protocol operation that removes a data node.";
+ position 365;
+ }
+ bit exec {
+ description "Execution access to the specified protocol operation.";
+ }
+ }
+ description "NETCONF Access Operation.";
+ }
+
+ leaf inst-id-leaf1 {
+ type instance-identifier {
+ require-instance false;
+ }
+ iit:mountpoint "mnt-extension";
+ }
+
+ leaf inst-id-leaf2 {
+ type instance-identifier;
+ }
+
+ leaf type {
+ type service-type-ref;
+ }
+
+ identity crypto-id {
+ base "crypto-base";
+ description "crypto-id description";
+ iit:mountpoint "mnt-extension";
+ }
+
+ identity crypto-base {
+ description "crypto-base description";
+ }
+
+ identity crypto-alg {
+ base "crypto-base";
+ description "crypto-alg description";
+ }
+
+ identity crypto-def {
+ base "crypto-base";
+ description "crypto-def description";
+ }
+
+ leaf mybits {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit 10-Mb-only {
+ position 2;
+ }
+ }
+ default "auto-sense-speed";
+ }
+
+ typedef ip-version {
+ type enumeration {
+ enum unknown {
+ description "An unknown or unspecified version of the Internet protocol.";
+ }
+ enum ipv4 {
+ value "19";
+ description "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum ipv6 {
+ value "7";
+ description "The IPv6 protocol as defined in RFC 2460.";
+ }
+ enum default {
+ description "default ip";
+ }
+ }
+ }
+
+ identity service-type {
+ description
+ "Service identity base type. All service identities must be
+ derived from this type. A service type uniquely defines a single
+ atomic API contract, such as a Java interface, a set of C
+ function declarations, or similar.
+
+ If the service type has a corresponding Java interface, the name
+ of that interface should be attached to the derived identity MUST
+ include a java-class keyword, whose name argument points to that
+ interface.";
+ }
+
+ typedef service-type-ref {
+ description
+ "Internal type of references to service type identity.";
+ type identityref {
+ base service-type;
+ }
+ }
+
+}