Bug 2366 - Effective statement implementation
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / DeviateStatementImpl.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;
9
10 import org.opendaylight.yangtools.yang.model.api.Deviation;
11 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviateEffectiveStatementImpl;
12
13 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
20
21 import javax.annotation.Nonnull;
22
23 public class DeviateStatementImpl extends AbstractDeclaredStatement<Deviation.Deviate> implements DeviateStatement {
24
25     protected DeviateStatementImpl(
26             StmtContext<Deviation.Deviate, DeviateStatement, ?> context) {
27         super(context);
28     }
29
30     public static class Definition extends AbstractStatementSupport<Deviation.Deviate,DeviateStatement,EffectiveStatement<Deviation.Deviate,DeviateStatement>> {
31
32         public Definition() {
33             super(Rfc6020Mapping.DEVIATE);
34         }
35
36         @Override public Deviation.Deviate parseArgumentValue(
37                 StmtContext<?, ?, ?> ctx, String value) throws SourceException {
38             return Utils.parseDeviateFromString(value);
39         }
40
41         @Override public DeviateStatement createDeclared(
42                 StmtContext<Deviation.Deviate, DeviateStatement, ?> ctx) {
43             return new DeviateStatementImpl(ctx);
44         }
45
46         @Override public EffectiveStatement<Deviation.Deviate, DeviateStatement> createEffective(
47                 StmtContext<Deviation.Deviate, DeviateStatement, EffectiveStatement<Deviation.Deviate, DeviateStatement>> ctx) {
48             return new DeviateEffectiveStatementImpl(ctx);
49         }
50
51     }
52
53     @Nonnull @Override
54     public Deviation.Deviate getValue() {
55         return argument();
56     }
57 }