Make CamelCaseWithNamespaceNamingStrategy reusable
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / AbstractNamespacedNamingStrategy.java
1 /*
2  * Copyright (c) 2023 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
16 /**
17  * A {@link ClassNamingStrategy} which considers a {@link StatementNamespace} when assigning names.
18  */
19 @NonNullByDefault
20 abstract class AbstractNamespacedNamingStrategy extends ClassNamingStrategy {
21     private final StatementNamespace namespace;
22
23     AbstractNamespacedNamingStrategy(final StatementNamespace namespace) {
24         this.namespace = requireNonNull(namespace);
25     }
26
27     @Override
28     final @NonNull ClassNamingStrategy fallback() {
29         return new AppendNamespaceNamingStrategy(this);
30     }
31
32     final StatementNamespace namespace() {
33         return namespace;
34     }
35
36     @Override
37     ToStringHelper addToStringAttributes(final ToStringHelper helper) {
38         return helper.add("namespace", namespace);
39     }
40 }