Bug 7038 - Rework 'type decimal64' lookup
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / TypeStatementRfc7950Support.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc. 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.stmt.rfc7950;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
14 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeStatementImpl;
15 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
16
17 /**
18  * Class providing necessary support for processing YANG 1.1 Type statement.
19  */
20 @Beta
21 public final class TypeStatementRfc7950Support extends TypeStatementImpl.Definition {
22     private static final Map<String, StatementSupport<?, ?, ?>> ARGUMENT_SPECIFIC_SUPPORTS = ImmutableMap
23             .<String, StatementSupport<?, ?, ?>> builder()
24             .put(TypeUtils.LEAF_REF, new LeafrefSpecificationRfc7950Support())
25             .put(TypeUtils.IDENTITY_REF, new IdentityrefSpecificationRfc7950Support()).build();
26
27     @Override
28     public boolean hasArgumentSpecificSupports() {
29         return !ARGUMENT_SPECIFIC_SUPPORTS.isEmpty() || super.hasArgumentSpecificSupports();
30     }
31
32     @Override
33     public StatementSupport<?, ?, ?> getSupportSpecificForArgument(final String argument) {
34         final StatementSupport<?, ?, ?> potential = ARGUMENT_SPECIFIC_SUPPORTS.get(argument);
35         return potential != null ? potential : super.getSupportSpecificForArgument(argument);
36     }
37 }