Log attempts to override fraction-digits 18/32018/2
authorRobert Varga <robert.varga@pantheon.sk>
Sat, 2 Jan 2016 15:07:00 +0000 (16:07 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 4 Jan 2016 08:56:25 +0000 (08:56 +0000)
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 <robert.varga@pantheon.sk>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/DecimalTypeEffectiveStatementImpl.java

index e867e4c569d0c8f1153ea4c76b100ff23532e4c8..536cdebc8c37b0a774317f8d961a13f856ef9116 100644 (file)
@@ -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<String, TypeStatement>
         implements TypeEffectiveStatement<TypeStatement> {
-
+    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());
+                }
             }
         }