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.yang.binding.contract.Naming;
16 * Naming strategy for {@code ietf-restconf:yang-data} template which has a generic string not matching YANG identifier.
19 final class YangDataNamingStrategy extends ClassNamingStrategy {
20 private final String javaIdentifier;
22 YangDataNamingStrategy(final String templateName) {
23 javaIdentifier = Naming.mapYangDataName(templateName);
27 String simpleClassName() {
28 return javaIdentifier;
32 @Nullable ClassNamingStrategy fallback() {
33 // javaIdentifier is guaranteed to be unique, there is no need for fallback
39 return javaIdentifier;
43 String childPackage() {
44 // javaIdentifier is always unique and provides an identifier which is suitable for package naming as well,
45 // except we need to further expand the package name so it does not class with the class.
46 // Since the strategy escapes '$', appending one cannot clash.
47 return javaIdentifier + '$';
51 ToStringHelper addToStringAttributes(final ToStringHelper helper) {
52 return helper.add("javaIdentifier", javaIdentifier);