+++ /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.rfc7950.stmt.type;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
-import org.opendaylight.yangtools.yang.model.util.type.TypeBuilder;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-abstract class AbstractTypeEffectiveStatement<T extends TypeDefinition<T>> extends
- DeclaredEffectiveStatementBase<String, TypeStatement> implements TypeEffectiveStatement<TypeStatement> {
- private final @NonNull T typeDefinition;
-
- AbstractTypeEffectiveStatement(
- final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
- final TypeBuilder<T> builder) {
- super(ctx);
-
- for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
- if (stmt instanceof UnknownSchemaNode) {
- builder.addUnknownSchemaNode((UnknownSchemaNode)stmt);
- }
- }
-
- typeDefinition = builder.build();
- }
-
- @Override
- public final T getTypeDefinition() {
- return typeDefinition;
- }
-}
return new IntegralTypeEffectiveStatementImpl<>(ctx,
RestrictedTypes.newUint64Builder((Uint64TypeDefinition) baseType, typeEffectiveSchemaPath(ctx)));
} else if (baseType instanceof UnionTypeDefinition) {
- return new UnionTypeEffectiveStatementImpl(ctx, (UnionTypeDefinition) baseType);
+ return createUnion(ctx, (UnionTypeDefinition) baseType, declared, substatements);
} else {
throw new IllegalStateException("Unhandled base type " + baseType);
}
typeEffectiveSchemaPath(ctx)));
}
+ private static @NonNull TypeEffectiveStatement<TypeStatement> createUnion(final StmtContext<?, ?, ?> ctx,
+ final UnionTypeDefinition baseType, final TypeStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new TypeEffectiveStatementImpl<>(declared, substatements, RestrictedTypes.newUnionBuilder(baseType,
+ typeEffectiveSchemaPath(ctx)));
+ }
}
\ No newline at end of file
+++ /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.rfc7950.stmt.type;
-
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
-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;
-
-final class UnionTypeEffectiveStatementImpl extends AbstractTypeEffectiveStatement<UnionTypeDefinition> {
- UnionTypeEffectiveStatementImpl(
- final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
- final UnionTypeDefinition baseType) {
- super(ctx, RestrictedTypes.newUnionBuilder(baseType,
- AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx)));
- }
-}