38c4c256f3bf0c8624175e23d9603a1fba2e3930
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / RevisionEffectiveStatementImpl.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 java.util.Optional;
11 import org.opendaylight.yangtools.yang.common.Revision;
12 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
13 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
15
16 public final class RevisionEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Revision, RevisionStatement>
17         implements DocumentedNode {
18
19     private final String reference;
20     private final String description;
21
22     public RevisionEffectiveStatementImpl(final StmtContext<Revision, RevisionStatement, ?> ctx) {
23         super(ctx);
24
25         final DescriptionEffectiveStatementImpl descStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
26         if (descStmt != null) {
27             this.description = descStmt.argument();
28         } else {
29             this.description = null;
30         }
31
32         final ReferenceEffectiveStatementImpl refStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
33         if (refStmt != null) {
34             this.reference = refStmt.argument();
35         } else {
36             this.reference = null;
37         }
38     }
39
40     @Override
41     public Optional<String> getDescription() {
42         return Optional.ofNullable(description);
43     }
44
45     @Override
46     public Optional<String> getReference() {
47         return Optional.ofNullable(reference);
48     }
49 }