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