2 * Copyright (c) 2023 PANTHEON.tech s.r.o. 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.generator.impl.reactor;
10 import com.google.common.base.MoreObjects.ToStringHelper;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.binding.lib.contract.Naming;
14 import org.opendaylight.yangtools.yang.common.YangDataName;
17 * Naming strategy for {@code ietf-restconf:yang-data} template which has a generic string not matching YANG identifier.
20 final class YangDataNamingStrategy extends ClassNamingStrategy {
21 private final String javaIdentifier;
23 YangDataNamingStrategy(final YangDataName templateName) {
24 javaIdentifier = Naming.mapYangDataName(templateName);
28 String simpleClassName() {
29 return javaIdentifier;
33 @Nullable ClassNamingStrategy fallback() {
34 // javaIdentifier is guaranteed to be unique, there is no need for fallback
40 return javaIdentifier;
44 String childPackage() {
45 // javaIdentifier is always unique and provides an identifier which is suitable for package naming as well,
46 // except we need to further expand the package name so it does not class with the class.
47 // Since the strategy escapes '$', appending one cannot clash.
48 return javaIdentifier + '$';
52 ToStringHelper addToStringAttributes(final ToStringHelper helper) {
53 return helper.add("javaIdentifier", javaIdentifier);