c8d4386a4bc43b7cb7a7a008a9871e080f3777c2
[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 com.google.common.collect.ImmutableMap;
14 import java.util.Collection;
15 import java.util.Map;
16 import java.util.Optional;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
19 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
20 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
22 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
23 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
24 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
25 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
26 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
27
28 /**
29  * Common shared effective statements for built-in types.
30  */
31 enum BuiltinEffectiveStatement implements TypeEffectiveStatement<TypeStatement> {
32     BINARY(BaseTypes.binaryType()),
33     BOOLEAN(BaseTypes.booleanType()),
34     EMPTY(BaseTypes.emptyType()),
35     INSTANCE_IDENTIFIER(BaseTypes.instanceIdentifierType()),
36     INT8(BaseTypes.int8Type()),
37     INT16(BaseTypes.int16Type()),
38     INT32(BaseTypes.int32Type()),
39     INT64(BaseTypes.int64Type()),
40     STRING(BaseTypes.stringType()),
41     UINT8(BaseTypes.uint8Type()),
42     UINT16(BaseTypes.uint16Type()),
43     UINT32(BaseTypes.uint32Type()),
44     UINT64(BaseTypes.uint64Type());
45
46     private final @NonNull TypeDefinition<?> typedef;
47
48     BuiltinEffectiveStatement(final TypeDefinition<?> typedef) {
49         this.typedef = requireNonNull(typedef);
50     }
51
52     @Override
53     public TypeDefinition<?> getTypeDefinition() {
54         return typedef;
55     }
56
57     @Override
58     public final TypeStatement getDeclared() {
59         return null;
60     }
61
62     @Override
63     public final <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends V> get(final Class<N> namespace,
64             final K identifier) {
65         // FIXME: 5.0.0: implement this
66         return Optional.empty();
67     }
68
69     @Override
70     public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
71         // FIXME: 5.0.0: implement this
72         return ImmutableMap.of();
73     }
74
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 }