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