2 * Copyright (c) 2021 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 com.google.common.base.MoreObjects;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.yang.common.AbstractQName;
19 * Enumeration of known strategies for translating a YANG node identifier into a Java package name segment or a Java
22 abstract class ClassNamingStrategy implements Immutable {
24 * Return the YANG node identifier backing this naming strategy. Only the {@link AbstractQName#getLocalName()} part
25 * of the identifier is significant.
27 * @return YANG node identifier.
29 abstract @NonNull AbstractQName nodeIdentifier();
32 * Return the simple Java class name assigned by this naming strategy.
34 * @return Simple class name
36 @NonNull String simpleClassName() {
37 return BindingMapping.getClassName(nodeIdentifier().getLocalName());
41 * Return the fallback naming strategy. The fallback is used if this strategy ends up being insufficient in
42 * assigning a unique name.
44 * @return Fallback strategy, {@code null} if there is no fallback.
46 abstract @Nullable ClassNamingStrategy fallback();
49 public final String toString() {
50 return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
53 abstract @NonNull ToStringHelper addToStringAttributes(@NonNull ToStringHelper helper);