2 * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import com.google.common.collect.ImmutableMap;
14 import java.util.Collection;
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;
29 * Common shared effective statements for built-in types.
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());
46 private final @NonNull TypeDefinition<?> typedef;
48 BuiltinEffectiveStatement(final TypeDefinition<?> typedef) {
49 this.typedef = requireNonNull(typedef);
53 public TypeDefinition<?> getTypeDefinition() {
58 public final TypeStatement getDeclared() {
63 public final <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends V> get(final Class<N> namespace,
65 // FIXME: 5.0.0: implement this
66 return Optional.empty();
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();
76 public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
77 return ImmutableList.of();
81 public final StatementDefinition statementDefinition() {
82 return YangStmtMapping.TYPE;
86 public final String argument() {
87 return getTypeDefinition().getQName().getLocalName();
91 public final StatementSource getStatementSource() {
92 return StatementSource.CONTEXT;