Make EffectiveStatement.get() more friendly
[yangtools.git] / parser / 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.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
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.StatementOrigin;
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.ri.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>> Optional<V> get(final Class<N> namespace,
63             final K identifier) {
64         // FIXME: 8.0.0: implement this
65         return Optional.empty();
66     }
67
68     @Override
69     public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
70         // FIXME: 8.0.0: implement this
71         return ImmutableMap.of();
72     }
73
74     @Override
75     public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
76         return ImmutableList.of();
77     }
78
79     @Override
80     public final QName argument() {
81         return getTypeDefinition().getQName();
82     }
83
84     @Override
85     public final StatementOrigin statementOrigin() {
86         return StatementOrigin.CONTEXT;
87     }
88 }