BUG-8043: eliminate ConstraintFactory
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / AbstractEffectiveDocumentedNode.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 javax.annotation.Nonnull;
11 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
12 import org.opendaylight.yangtools.yang.model.api.Status;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
15
16 public abstract class AbstractEffectiveDocumentedNode<A, D extends DeclaredStatement<A>>
17         extends DeclaredEffectiveStatementBase<A, D> implements DocumentedNode.WithStatus {
18
19     private final String description;
20     private final String reference;
21     private final Status status;
22
23     /**
24      * Constructor.
25      *
26      * @param ctx
27      *            context of statement.
28      */
29     protected AbstractEffectiveDocumentedNode(final StmtContext<A, D, ?> ctx) {
30         super(ctx);
31
32         final DescriptionEffectiveStatementImpl descStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
33         if (descStmt != null) {
34             description = descStmt.argument();
35         } else {
36             description = null;
37         }
38
39         final ReferenceEffectiveStatementImpl refStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
40         if (refStmt != null) {
41             reference = refStmt.argument();
42         } else {
43             reference = null;
44         }
45
46         final StatusEffectiveStatementImpl statusStmt = firstEffective(StatusEffectiveStatementImpl.class);
47         if (statusStmt != null) {
48             status = statusStmt.argument();
49         } else {
50             status = Status.CURRENT;
51         }
52     }
53
54     @Override
55     public final String getDescription() {
56         return description;
57     }
58
59     @Override
60     public final String getReference() {
61         return reference;
62     }
63
64     @Nonnull
65     @Override
66     public final Status getStatus() {
67         return status;
68     }
69 }