2 * Copyright (c) 2018 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.mdsal.binding.dom.codec.util;
10 import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
11 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
12 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
13 import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
15 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
17 public final class BindingSchemaMapping {
18 private BindingSchemaMapping() {
22 public static String getGetterMethodName(final DataSchemaNode node) {
23 return node instanceof TypedDataSchemaNode ? getGetterMethodName((TypedDataSchemaNode) node)
24 : BindingMapping.getGetterMethodName(node.getQName(), false);
27 public static String getGetterMethodName(final TypedDataSchemaNode node) {
28 // Bug 8903: If it is a derived type of boolean or empty, not an inner type, then the return type
29 // of method would be the generated type of typedef not build-in types, so here it should be 'get'.
30 final TypeDefinition<?> type = node.getType();
31 return BindingMapping.getGetterMethodName(node.getQName(),
32 (type instanceof BooleanTypeDefinition || type instanceof EmptyTypeDefinition)
33 && (type.getPath().equals(node.getPath()) || type.getBaseType() == null));