2 * Copyright (c) 2023 PANTHEON.tech, 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.generator.impl.reactor;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.yang.binding.contract.Naming;
15 import org.opendaylight.yangtools.yang.common.AbstractQName;
18 * A {@link ClassNamingStrategy} which is based on a YANG node identifier as captured in
19 * {@link AbstractQName#getLocalName()}.
22 abstract class YangIdentifierClassNamingStrategy extends ClassNamingStrategy {
23 private final AbstractQName nodeIdentifier;
25 YangIdentifierClassNamingStrategy(final AbstractQName nodeIdentifier) {
26 this.nodeIdentifier = requireNonNull(nodeIdentifier);
30 final String simpleClassName() {
31 return Naming.getClassName(rootName());
35 final String rootName() {
36 return nodeIdentifier.getLocalName();
40 final String childPackage() {
41 return CollisionDomain.packageString(nodeIdentifier);
45 ToStringHelper addToStringAttributes(final ToStringHelper helper) {
46 return helper.add("localName", rootName());