*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.util.Collection;
import java.util.Map;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
+import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
abstract class AbstractTypeStatementSupport
extends AbstractStatementSupport<String, TypeStatement, EffectiveStatement<String, TypeStatement>> {
(InstanceIdentifierTypeDefinition) baseType);
} else if (baseType instanceof Int8TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newInt8Builder((Int8TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newInt8Builder((Int8TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof Int16TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newInt16Builder((Int16TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newInt16Builder((Int16TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof Int32TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newInt32Builder((Int32TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newInt32Builder((Int32TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof Int64TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newInt64Builder((Int64TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newInt64Builder((Int64TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof LeafrefTypeDefinition) {
return new LeafrefTypeEffectiveStatementImpl(ctx, (LeafrefTypeDefinition) baseType);
} else if (baseType instanceof StringTypeDefinition) {
return new StringTypeEffectiveStatementImpl(ctx, (StringTypeDefinition) baseType);
} else if (baseType instanceof Uint8TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newUint8Builder((Uint8TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newUint8Builder((Uint8TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof Uint16TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newUint16Builder((Uint16TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newUint16Builder((Uint16TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof Uint32TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newUint32Builder((Uint32TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newUint32Builder((Uint32TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof Uint64TypeDefinition) {
return new IntegralTypeEffectiveStatementImpl<>(ctx,
- RestrictedTypes.newUint64Builder((Uint64TypeDefinition) baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx)));
+ RestrictedTypes.newUint64Builder((Uint64TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof UnionTypeDefinition) {
return new UnionTypeEffectiveStatementImpl(ctx, (UnionTypeDefinition) baseType);
} else {
public StatementSupport<?, ?, ?> getSupportSpecificForArgument(final String argument) {
return ARGUMENT_SPECIFIC_SUPPORTS.get(argument);
}
+
+ static final SchemaPath typeEffectiveSchemaPath(final StmtContext<?, ?, ?> stmtCtx) {
+ final SchemaPath path = stmtCtx.getSchemaPath().get();
+ final SchemaPath parent = path.getParent();
+ final QName parentQName = parent.getLastComponent();
+ Preconditions.checkArgument(parentQName != null, "Path %s has an empty parent", path);
+
+ final QName qname = stmtCtx.getFromNamespace(QNameCacheNamespace.class,
+ QName.create(parentQName, path.getLastComponent().getLocalName()));
+ return parent.createChild(qname);
+ }
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.length.LengthEffectiveStatementImpl;
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.TypeUtils;
final class BinaryTypeEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, TypeStatement>
implements TypeEffectiveStatement<TypeStatement> {
super(ctx);
final LengthRestrictedTypeBuilder<BinaryTypeDefinition> builder =
- RestrictedTypes.newBinaryBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx));
+ RestrictedTypes.newBinaryBuilder(baseType, AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx));
for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof LengthEffectiveStatementImpl) {
import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
final class BooleanTypeEffectiveStatementImpl extends AbstractTypeEffectiveStatement<BooleanTypeDefinition> {
BooleanTypeEffectiveStatementImpl(
final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
final BooleanTypeDefinition baseType) {
- super(ctx, RestrictedTypes.newBooleanBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx)));
+ super(ctx, RestrictedTypes.newBooleanBuilder(baseType,
+ AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx)));
}
}
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.range.RangeEffectiveStatementImpl;
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.TypeUtils;
final class DecimalTypeEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, TypeStatement>
implements TypeEffectiveStatement<TypeStatement> {
super(ctx);
final RangeRestrictedTypeBuilder<DecimalTypeDefinition, BigDecimal> builder =
- RestrictedTypes.newDecima64Builder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx));
+ RestrictedTypes.newDecima64Builder(baseType, AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx));
for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof RangeEffectiveStatementImpl) {
import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
final class EmptyTypeEffectiveStatementImpl extends AbstractTypeEffectiveStatement<EmptyTypeDefinition> {
EmptyTypeEffectiveStatementImpl(
final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
final EmptyTypeDefinition baseType) {
- super(ctx, RestrictedTypes.newEmptyBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx)));
+ super(ctx, RestrictedTypes.newEmptyBuilder(baseType,
+ AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx)));
}
}
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
final class IdentityrefTypeEffectiveStatementImpl extends AbstractTypeEffectiveStatement<IdentityrefTypeDefinition> {
IdentityrefTypeEffectiveStatementImpl(
final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
final IdentityrefTypeDefinition baseType) {
- super(ctx, RestrictedTypes.newIdentityrefBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx)));
+ super(ctx, RestrictedTypes.newIdentityrefBuilder(baseType,
+ AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx)));
}
}
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
final class InstanceIdentifierTypeEffectiveStatementImpl
extends DeclaredEffectiveStatementBase<String, TypeStatement> implements TypeEffectiveStatement<TypeStatement> {
super(ctx);
final InstanceIdentifierTypeBuilder builder =
- RestrictedTypes.newInstanceIdentifierBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx));
+ RestrictedTypes.newInstanceIdentifierBuilder(baseType,
+ AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx));
for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof RequireInstanceEffectiveStatement) {
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
final class LeafrefTypeEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, TypeStatement>
implements TypeEffectiveStatement<TypeStatement> {
super(ctx);
final RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition> builder =
- RestrictedTypes.newLeafrefBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx));
+ RestrictedTypes.newLeafrefBuilder(baseType, AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx));
for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof RequireInstanceEffectiveStatement) {
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.length.LengthEffectiveStatementImpl;
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.TypeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
super(ctx);
final StringTypeBuilder builder = RestrictedTypes.newStringBuilder(baseType,
- TypeUtils.typeEffectiveSchemaPath(ctx));
+ AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx));
for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof LengthEffectiveStatementImpl) {
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
final class UnionTypeEffectiveStatementImpl extends AbstractTypeEffectiveStatement<UnionTypeDefinition> {
UnionTypeEffectiveStatementImpl(
final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
final UnionTypeDefinition baseType) {
- super(ctx, RestrictedTypes.newUnionBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx)));
+ super(ctx, RestrictedTypes.newUnionBuilder(baseType,
+ AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx)));
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
return ranges;
}
- public static SchemaPath typeEffectiveSchemaPath(final StmtContext<?, ?, ?> stmtCtx) {
- final SchemaPath path = stmtCtx.getSchemaPath().get();
- final SchemaPath parent = path.getParent();
- final QName parentQName = parent.getLastComponent();
- Preconditions.checkArgument(parentQName != null, "Path %s has an empty parent", path);
-
- final QName qname = stmtCtx.getFromNamespace(QNameCacheNamespace.class,
- QName.create(parentQName, path.getLastComponent().getLocalName()));
- return parent.createChild(qname);
- }
-
/**
* Checks whether supplied type has any of specified default values marked
* with an if-feature. This method creates mutable copy of supplied set of