From 914ae3e8d065887390269b910e9deb6a0397b866 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 2 Jul 2020 19:43:56 +0200 Subject: [PATCH] Consolidate BooleanTypeEffectiveStatementImpl TypeEffectiveStatementImpl can easily support the case of a boolean type, migrate it. JIRA: YANGTOOLS-1065 Change-Id: I24bc5fa4909710805d9503db69ed49f65878e1af Signed-off-by: Robert Varga --- .../type/AbstractTypeStatementSupport.java | 9 +++++++- .../BooleanTypeEffectiveStatementImpl.java | 23 ------------------- 2 files changed, 8 insertions(+), 24 deletions(-) delete mode 100644 yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BooleanTypeEffectiveStatementImpl.java diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java index f2d4ddb3f7..bf17401ba6 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java @@ -219,7 +219,7 @@ abstract class AbstractTypeStatementSupport } else if (baseType instanceof BitsTypeDefinition) { return new BitsTypeEffectiveStatementImpl(ctx, (BitsTypeDefinition) baseType); } else if (baseType instanceof BooleanTypeDefinition) { - return new BooleanTypeEffectiveStatementImpl(ctx, (BooleanTypeDefinition) baseType); + return createBoolean(ctx, (BooleanTypeDefinition) baseType, declared, substatements); } else if (baseType instanceof DecimalTypeDefinition) { return new DecimalTypeEffectiveStatementImpl(ctx, (DecimalTypeDefinition) baseType); } else if (baseType instanceof EmptyTypeDefinition) { @@ -352,4 +352,11 @@ abstract class AbstractTypeStatementSupport return new TypeEffectiveStatementImpl<>(declared, substatements, builder); } + + private static @NonNull TypeEffectiveStatement createBoolean(final StmtContext ctx, + final BooleanTypeDefinition baseType, final TypeStatement declared, + final ImmutableList> substatements) { + return new TypeEffectiveStatementImpl<>(declared, substatements, RestrictedTypes.newBooleanBuilder(baseType, + typeEffectiveSchemaPath(ctx))); + } } \ No newline at end of file diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BooleanTypeEffectiveStatementImpl.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BooleanTypeEffectiveStatementImpl.java deleted file mode 100644 index 179dfee7cc..0000000000 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BooleanTypeEffectiveStatementImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.BooleanTypeDefinition; -import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes; -import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; - -final class BooleanTypeEffectiveStatementImpl extends AbstractTypeEffectiveStatement { - BooleanTypeEffectiveStatementImpl( - final StmtContext> ctx, - final BooleanTypeDefinition baseType) { - super(ctx, RestrictedTypes.newBooleanBuilder(baseType, - AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx))); - } -} -- 2.36.6