Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / type / 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.rfc7950.stmt.type;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableMap;
12 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
13
14 /**
15  * Class providing necessary support for processing YANG 1.1 Type statement.
16  */
17 @Beta
18 public final class TypeStatementRFC7950Support extends AbstractTypeStatementSupport {
19     private static final ImmutableMap<String, StatementSupport<?, ?, ?>> ARGUMENT_SPECIFIC_SUPPORTS = ImmutableMap.of(
20         LEAF_REF, new LeafrefSpecificationRFC7950Support(),
21         IDENTITY_REF, new IdentityrefSpecificationRFC7950Support());
22     private static final TypeStatementRFC7950Support INSTANCE = new TypeStatementRFC7950Support();
23
24     private TypeStatementRFC7950Support() {
25         // Hidden
26     }
27
28     public static TypeStatementRFC7950Support getInstance() {
29         return INSTANCE;
30     }
31
32     @Override
33     public boolean hasArgumentSpecificSupports() {
34         return !ARGUMENT_SPECIFIC_SUPPORTS.isEmpty() || super.hasArgumentSpecificSupports();
35     }
36
37     @Override
38     public StatementSupport<?, ?, ?> getSupportSpecificForArgument(final String argument) {
39         final StatementSupport<?, ?, ?> potential = ARGUMENT_SPECIFIC_SUPPORTS.get(argument);
40         return potential != null ? potential : super.getSupportSpecificForArgument(argument);
41     }
42 }