Bug 2366 - Effective statments impl merge, retest & bugfix
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / BinarySpecificationImpl.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 javax.annotation.Nonnull;
11 import javax.annotation.Nullable;
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.LengthStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BinaryEffectiveStatementImpl;
22
23 public class BinarySpecificationImpl extends AbstractDeclaredStatement<String> implements
24         TypeStatement.BinarySpecification {
25
26     protected BinarySpecificationImpl(StmtContext<String, ?, ?> context) {
27         super(context);
28     }
29
30     public static class Definition extends
31             AbstractStatementSupport<String, BinarySpecification, EffectiveStatement<String, BinarySpecification>> {
32
33         public Definition() {
34             super(Rfc6020Mapping.TYPE);
35         }
36
37         @Override
38         public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
39             return value;
40         }
41
42         @Override
43         public BinarySpecification createDeclared(StmtContext<String, BinarySpecification, ?> ctx) {
44             return new BinarySpecificationImpl(ctx);
45         }
46
47         @Override
48         public EffectiveStatement<String, BinarySpecification> createEffective(
49                 StmtContext<String, BinarySpecification, EffectiveStatement<String, BinarySpecification>> ctx) {
50             return new BinaryEffectiveStatementImpl(ctx);
51         }
52     }
53
54     @Nullable
55     @Override
56     public LengthStatement getLength() {
57         return firstDeclared(LengthStatement.class);
58     }
59
60     @Nonnull
61     @Override
62     public String getName() {
63         return argument();
64     }
65 }