Separate out YangIdentifierClassNamingStrategy
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / CamelCaseWithNamespaceNamingStrategy.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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.MoreObjects.ToStringHelper;
13
14 final class CamelCaseWithNamespaceNamingStrategy extends ClassNamingStrategy {
15     private final CamelCaseNamingStrategy delegate;
16
17     CamelCaseWithNamespaceNamingStrategy(final CamelCaseNamingStrategy delegate) {
18         this.delegate = requireNonNull(delegate);
19     }
20
21     @Override
22     String simpleClassName() {
23         return delegate.namespace().appendSuffix(delegate.simpleClassName());
24     }
25
26     @Override
27     ClassNamingStrategy fallback() {
28         // FIXME: MDSAL-503: add a BijectiveNamingStrategy
29         //        The algorithm needs to essentially fall back to using escape-based translation scheme, where each
30         //        localName results in a unique name, while not conflicting with any possible preferredName. The exact
31         //        mechanics for that are TBD. A requirement for that mapping is that it must not rely on definition
32         //        order.
33         //
34         //        But there is another possible step: since we are assigning 14 different statements into the default
35         //        namespace (which did not add a suffix), we can try to assign a statement-derived suffix. To make
36         //        things easier, we use two-characters: AC, AD, AU, AX, CA, CH, CO, IP, LE, LI, LL, NO, OP, RP.
37         return null;
38     }
39
40     @Override
41     String rootName() {
42         return delegate.rootName();
43     }
44
45     @Override
46     String childPackage() {
47         return delegate.childPackage();
48     }
49
50     @Override
51     ToStringHelper addToStringAttributes(final ToStringHelper helper) {
52         return helper.add("delegate", delegate);
53     }
54 }