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