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;
16 public final class BindingSchemaMapping {
17 private BindingSchemaMapping() {
21 public static String getGetterMethodName(final DataSchemaNode node) {
22 return node instanceof TypedDataSchemaNode ? getGetterMethodName((TypedDataSchemaNode) node)
23 : BindingMapping.getGetterMethodName(node.getQName(), false);
26 public static String getGetterMethodName(final TypedDataSchemaNode node) {
27 // Bug 8903: If it is a derived type of boolean, not an inner type, then the return type
28 // of method would be the generated type of typedef not build-in types, so here it should be 'get'.
29 final TypeDefinition<?> type = node.getType();
30 return BindingMapping.getGetterMethodName(node.getQName(),
31 type instanceof BooleanTypeDefinition
32 && (type.getPath().equals(node.getPath()) || type.getBaseType() == null));