6d79510f9e75030771783a45946fffb0fa69398b
[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 org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
11
12 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
13 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
14 import org.opendaylight.yangtools.yang.model.api.Status;
15
16 public abstract class AbstractEffectiveDocumentedNode<A, D extends DeclaredStatement<A>>
17         extends EffectiveStatementBase<A, D> implements DocumentedNode {
18
19     private final String description;
20     private final String reference;
21     private final Status status;
22
23     AbstractEffectiveDocumentedNode(final StmtContext<A, D, ?> ctx) {
24         super(ctx);
25
26         DescriptionEffectiveStatementImpl descStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
27         if (descStmt != null) {
28             description = descStmt.argument();
29         } else {
30             description = null;
31         }
32
33         ReferenceEffectiveStatementImpl refStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
34         if (refStmt != null) {
35             reference = refStmt.argument();
36         } else {
37             RevisionEffectiveStatementImpl revision = firstEffective(RevisionEffectiveStatementImpl.class);
38             if (revision != null) {
39                 reference = revision.getReference();
40             } else {
41                 reference = null;
42             }
43         }
44
45         StatusEffectiveStatementImpl statusStmt = firstEffective(StatusEffectiveStatementImpl.class);
46         if (statusStmt != null) {
47             status = statusStmt.argument();
48         } else {
49             status = Status.CURRENT;
50         }
51     }
52
53     @Override
54     public final String getDescription() {
55         return description;
56     }
57
58     @Override
59     public final String getReference() {
60         return reference;
61     }
62
63     @Override
64     public final Status getStatus() {
65         return status;
66     }
67
68 }