Bug 4079: Unable to compile pattern defined in module
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / StatusStatementImpl.java
index b7401e56d2d5ebc940c49d61c6631475ca809eb3..6c75b68e931b940e7ad12ee533998fe54f170583 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -7,52 +7,63 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl;
-
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 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.effective.StatusEffectiveStatementImpl;
 
-public class StatusStatementImpl extends AbstractDeclaredStatement<String>
+public class StatusStatementImpl extends AbstractDeclaredStatement<Status>
         implements StatusStatement {
+    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
+            .STATUS)
+            .build();
 
     protected StatusStatementImpl(
-            StmtContext<String, StatusStatement, ?> context) {
+            StmtContext<Status, StatusStatement, ?> context) {
         super(context);
     }
 
     public static class Definition
             extends
-            AbstractStatementSupport<String, StatusStatement, EffectiveStatement<String, StatusStatement>> {
+            AbstractStatementSupport<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> {
 
         public Definition() {
             super(Rfc6020Mapping.STATUS);
         }
 
         @Override
-        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
-            return value;
+        public Status parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.parseStatus(value);
         }
 
         @Override
         public StatusStatement createDeclared(
-                StmtContext<String, StatusStatement, ?> ctx) {
+                StmtContext<Status, StatusStatement, ?> ctx) {
             return new StatusStatementImpl(ctx);
         }
 
         @Override
-        public EffectiveStatement<String, StatusStatement> createEffective(
-                StmtContext<String, StatusStatement, EffectiveStatement<String, StatusStatement>> ctx) {
+        public EffectiveStatement<Status, StatusStatement> createEffective(
+                StmtContext<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> ctx) {
             return new StatusEffectiveStatementImpl(ctx);
         }
 
+        @Override
+        public void onFullDefinitionDeclared(StmtContext.Mutable<Status, StatusStatement,
+                EffectiveStatement<Status, StatusStatement>> stmt) throws SourceException {
+            super.onFullDefinitionDeclared(stmt);
+            SUBSTATEMENT_VALIDATOR.validate(stmt);
+        }
     }
 
     @Override
-    public String getValue() {
+    public Status getValue() {
         return argument();
     }