import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BinaryTypeEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BitsTypeEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BooleanTypeEffectiveStatementImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BuiltinEffectiveStatements;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BuiltinEffectiveStatement;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.DecimalTypeEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.EmptyTypeEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.EnumTypeEffectiveStatementImpl;
final TypeEffectiveStatement<TypeStatement> typeStmt;
switch (ctx.getStatementArgument()) {
case TypeUtils.BINARY:
- typeStmt = BuiltinEffectiveStatements.BINARY;
+ typeStmt = BuiltinEffectiveStatement.BINARY;
break;
case TypeUtils.BOOLEAN:
- typeStmt = BuiltinEffectiveStatements.BOOLEAN;
+ typeStmt = BuiltinEffectiveStatement.BOOLEAN;
break;
case TypeUtils.EMPTY:
- typeStmt = BuiltinEffectiveStatements.EMPTY;
+ typeStmt = BuiltinEffectiveStatement.EMPTY;
break;
case TypeUtils.INSTANCE_IDENTIFIER:
- typeStmt = BuiltinEffectiveStatements.INSTANCE_IDENTIFIER;
+ typeStmt = BuiltinEffectiveStatement.INSTANCE_IDENTIFIER;
break;
case TypeUtils.INT8:
- typeStmt = BuiltinEffectiveStatements.INT8;
+ typeStmt = BuiltinEffectiveStatement.INT8;
break;
case TypeUtils.INT16:
- typeStmt = BuiltinEffectiveStatements.INT16;
+ typeStmt = BuiltinEffectiveStatement.INT16;
break;
case TypeUtils.INT32:
- typeStmt = BuiltinEffectiveStatements.INT32;
+ typeStmt = BuiltinEffectiveStatement.INT32;
break;
case TypeUtils.INT64:
- typeStmt = BuiltinEffectiveStatements.INT64;
+ typeStmt = BuiltinEffectiveStatement.INT64;
break;
case TypeUtils.STRING:
- typeStmt = BuiltinEffectiveStatements.STRING;
+ typeStmt = BuiltinEffectiveStatement.STRING;
break;
case TypeUtils.UINT8:
- typeStmt = BuiltinEffectiveStatements.UINT8;
+ typeStmt = BuiltinEffectiveStatement.UINT8;
break;
case TypeUtils.UINT16:
- typeStmt = BuiltinEffectiveStatements.UINT16;
+ typeStmt = BuiltinEffectiveStatement.UINT16;
break;
case TypeUtils.UINT32:
- typeStmt = BuiltinEffectiveStatements.UINT32;
+ typeStmt = BuiltinEffectiveStatement.UINT32;
break;
case TypeUtils.UINT64:
- typeStmt = BuiltinEffectiveStatements.UINT64;
+ typeStmt = BuiltinEffectiveStatement.UINT64;
break;
default:
final QName qname = Utils.qNameFromArgument(ctx, ctx.getStatementArgument());
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.Map;
import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
+
+/**
+ * Common shared effective statements for built-in types.
+ */
+public enum BuiltinEffectiveStatement implements TypeEffectiveStatement<TypeStatement> {
+ BINARY(BaseTypes.binaryType()),
+ BOOLEAN(BaseTypes.booleanType()),
+ EMPTY(BaseTypes.emptyType()),
+ INSTANCE_IDENTIFIER(BaseTypes.instanceIdentifierType()),
+ INT8(BaseTypes.int8Type()),
+ INT16(BaseTypes.int16Type()),
+ INT32(BaseTypes.int32Type()),
+ INT64(BaseTypes.int64Type()),
+ STRING(BaseTypes.stringType()),
+ UINT8(BaseTypes.uint8Type()),
+ UINT16(BaseTypes.uint16Type()),
+ UINT32(BaseTypes.uint32Type()),
+ UINT64(BaseTypes.uint64Type());
+
+ private final TypeDefinition<?> typedef;
+
+ BuiltinEffectiveStatement(final TypeDefinition<?> typedef) {
+ this.typedef = Preconditions.checkNotNull(typedef);
+ }
+
+ @Override
+ public @Nonnull TypeDefinition<?> getTypeDefinition() {
+ return typedef;
+ }
-abstract class AbstractBuiltinEffectiveStatement implements TypeEffectiveStatement<TypeStatement> {
@Override
public final TypeStatement getDeclared() {
return null;
+++ /dev/null
-/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type;
-
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
-import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
-
-public final class BuiltinEffectiveStatements {
- private BuiltinEffectiveStatements() {
- throw new UnsupportedOperationException();
- }
-
- public static final TypeEffectiveStatement<TypeStatement> BINARY = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public BinaryTypeDefinition getTypeDefinition() {
- return BaseTypes.binaryType();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> BOOLEAN = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public BooleanTypeDefinition getTypeDefinition() {
- return BaseTypes.booleanType();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> EMPTY = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public EmptyTypeDefinition getTypeDefinition() {
- return BaseTypes.emptyType();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> INSTANCE_IDENTIFIER = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public InstanceIdentifierTypeDefinition getTypeDefinition() {
- return BaseTypes.instanceIdentifierType();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> INT8 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public IntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.int8Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> INT16 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public IntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.int16Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> INT32 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public IntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.int32Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> INT64 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public IntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.int64Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> STRING = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public StringTypeDefinition getTypeDefinition() {
- return BaseTypes.stringType();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> UINT8 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public UnsignedIntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.uint8Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> UINT16 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public UnsignedIntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.uint16Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> UINT32 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public UnsignedIntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.uint32Type();
- }
- };
- public static final TypeEffectiveStatement<TypeStatement> UINT64 = new AbstractBuiltinEffectiveStatement() {
- @Nonnull
- @Override
- public UnsignedIntegerTypeDefinition getTypeDefinition() {
- return BaseTypes.uint64Type();
- }
- };
-}