e82ec102888aacf38d9adfc07fd954a2f55220c9
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / type / BuiltinEffectiveStatement.java
1 /*
2  * Copyright (c) 2015 Pantheon Technologies s.r.o. 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.type;
9
10 import com.google.common.base.Preconditions;
11 import com.google.common.collect.ImmutableList;
12 import java.util.Collection;
13 import java.util.Map;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
16 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
19 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
20 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
21 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
22 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
23 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
24
25 /**
26  * Common shared effective statements for built-in types.
27  */
28 public enum BuiltinEffectiveStatement implements TypeEffectiveStatement<TypeStatement> {
29     BINARY(BaseTypes.binaryType()),
30     BOOLEAN(BaseTypes.booleanType()),
31     EMPTY(BaseTypes.emptyType()),
32     INSTANCE_IDENTIFIER(BaseTypes.instanceIdentifierType()),
33     INT8(BaseTypes.int8Type()),
34     INT16(BaseTypes.int16Type()),
35     INT32(BaseTypes.int32Type()),
36     INT64(BaseTypes.int64Type()),
37     STRING(BaseTypes.stringType()),
38     UINT8(BaseTypes.uint8Type()),
39     UINT16(BaseTypes.uint16Type()),
40     UINT32(BaseTypes.uint32Type()),
41     UINT64(BaseTypes.uint64Type());
42
43     private final TypeDefinition<?> typedef;
44
45     BuiltinEffectiveStatement(final TypeDefinition<?> typedef) {
46         this.typedef = Preconditions.checkNotNull(typedef);
47     }
48
49     @Override
50     public @Nonnull TypeDefinition<?> getTypeDefinition() {
51         return typedef;
52     }
53
54     @Override
55     public final TypeStatement getDeclared() {
56         return null;
57     }
58
59     @Override
60     public final <K, V, N extends IdentifierNamespace<K, V>> V get(@Nonnull final Class<N> namespace,
61             @Nonnull final K identifier) {
62         // TODO Auto-generated method stub
63         return null;
64     }
65
66     @Override
67     public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(@Nonnull final Class<N> namespace) {
68         // TODO Auto-generated method stub
69         return null;
70     }
71
72     @Nonnull
73     @Override
74     public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
75         return ImmutableList.of();
76     }
77
78     @Nonnull
79     @Override
80     public final StatementDefinition statementDefinition() {
81         return YangStmtMapping.TYPE;
82     }
83
84     @Override
85     public final String argument() {
86         return getTypeDefinition().getQName().getLocalName();
87     }
88
89     @Nonnull
90     @Override
91     public final StatementSource getStatementSource() {
92         return StatementSource.CONTEXT;
93     }
94 }