Bug 5884: Augmenting a choice without a case results in no getter
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / UndeclaredEffectiveStatementBase.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
9
10 import com.google.common.base.Verify;
11 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
12 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
13 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
15
16 public abstract class UndeclaredEffectiveStatementBase<A, D extends DeclaredStatement<A>> extends EffectiveStatementBase<A, D> {
17
18     private final StatementSource statementSource;
19     private final StatementDefinition statementDefinition;
20     private final A argument;
21
22     protected UndeclaredEffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
23         super(ctx);
24         this.statementDefinition = ctx.getPublicDefinition();
25         this.argument = ctx.getStatementArgument();
26         this.statementSource = ctx.getStatementSource();
27
28         final D declareInstance = ctx.buildDeclared();
29         Verify.verify(declareInstance == null, "Statement %s resulted in declared statement %s", declareInstance);
30     }
31
32     @Override
33     public final StatementDefinition statementDefinition() {
34         return statementDefinition;
35     }
36
37     @Override
38     public final A argument() {
39         return argument;
40     }
41
42     @Override
43     public final StatementSource getStatementSource() {
44         return statementSource;
45     }
46
47     @Override
48     public final D getDeclared() {
49         return null;
50     }
51 }