Expand StatementNamespace
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / CamelCaseNamingStrategy.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.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.opendaylight.yangtools.yang.common.AbstractQName;
16
17 @NonNullByDefault
18 final class CamelCaseNamingStrategy extends YangIdentifierClassNamingStrategy {
19     private final StatementNamespace namespace;
20
21     CamelCaseNamingStrategy(final StatementNamespace namespace, final AbstractQName nodeIdentifier) {
22         super(nodeIdentifier);
23         this.namespace = requireNonNull(namespace);
24     }
25
26     StatementNamespace namespace() {
27         return namespace;
28     }
29
30     @Override
31     @NonNull ClassNamingStrategy fallback() {
32         return namespace.resistant() ? new ResistedCamelCaseNamingStrategy(this)
33             : new CamelCaseWithNamespaceNamingStrategy(this);
34     }
35
36     @Override
37     ToStringHelper addToStringAttributes(final ToStringHelper helper) {
38         return super.addToStringAttributes(helper).add("namespace", namespace);
39     }
40 }