From e3ae476c2621f5f48de6a989c73d92af29368ab7 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 2 Jan 2016 16:07:00 +0100 Subject: [PATCH] Log attempts to override fraction-digits We should emit a warning when a model attempts to override fraction-digits from a base type. Change-Id: I2aa801288fff8894cc8b8afe22f27c19630e2331 Signed-off-by: Robert Varga --- .../DecimalTypeEffectiveStatementImpl.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/DecimalTypeEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/DecimalTypeEffectiveStatementImpl.java index e867e4c569..536cdebc8c 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/DecimalTypeEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/DecimalTypeEffectiveStatementImpl.java @@ -19,10 +19,12 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.FractionDigitsEffectiveStatementImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class DecimalTypeEffectiveStatementImpl extends DeclaredEffectiveStatementBase implements TypeEffectiveStatement { - + private static final Logger LOG = LoggerFactory.getLogger(Decimal64SpecificationEffectiveStatementImpl.class); private final DecimalTypeDefinition typeDefinition; public DecimalTypeEffectiveStatementImpl( @@ -42,11 +44,15 @@ public final class DecimalTypeEffectiveStatementImpl extends DeclaredEffectiveSt } if (stmt instanceof FractionDigitsEffectiveStatementImpl) { final Integer digits = ((FractionDigitsEffectiveStatementImpl)stmt).argument(); -// FIXME: activate this and fix models -// if (!baseType.getFractionDigits().equals(digits)) { -// throw new SourceException(String.format("Cannot override fraction-digits from base type %s", -// baseType), ctx.getStatementSourceReference()); -// } + + if (!baseType.getFractionDigits().equals(digits)) { + LOG.warn("Ignoring attempt to override fraction-digits to {} at {}, base type is {}", digits, + ctx.getStatementSourceReference(), baseType); + + // FIXME: promote to a full error once our models are fixed + // throw new SourceException(String.format("Cannot override fraction-digits from base type %s", + // baseType), ctx.getStatementSourceReference()); + } } } -- 2.36.6