Move ClassNamingStrategy.simpleClassName()
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / ClassNamingStrategy.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.generator.impl.reactor;
9
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.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.yang.common.AbstractQName;
16
17 /**
18  * Enumeration of known strategies for translating a YANG node identifier into a Java package name segment or a Java
19  * simple class name.
20  */
21 abstract class ClassNamingStrategy implements Immutable {
22     /**
23      * Return the YANG node identifier backing this naming strategy. Only the {@link AbstractQName#getLocalName()} part
24      * of the identifier is significant.
25      *
26      * @return YANG node identifier.
27      */
28     abstract @NonNull AbstractQName nodeIdentifier();
29
30     /**
31      * Return the simple Java class name assigned by this naming strategy.
32      *
33      * @return Simple class name
34      */
35     abstract @NonNull String simpleClassName();
36
37     /**
38      * Return the fallback naming strategy. The fallback is used if this strategy ends up being insufficient in
39      * assigning a unique name.
40      *
41      * @return Fallback strategy, {@code null} if there is no fallback.
42      */
43     abstract @Nullable ClassNamingStrategy fallback();
44
45     @Override
46     public final String toString() {
47         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
48     }
49
50     abstract @NonNull ToStringHelper addToStringAttributes(@NonNull ToStringHelper helper);
51 }