--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.binding.generator.impl.reactor;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.base.MoreObjects.ToStringHelper;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * A {@link ClassNamingStrategy} which considers a {@link StatementNamespace} when assigning names.
+ */
+@NonNullByDefault
+abstract class AbstractNamespacedNamingStrategy extends ClassNamingStrategy {
+ private final StatementNamespace namespace;
+
+ AbstractNamespacedNamingStrategy(final StatementNamespace namespace) {
+ this.namespace = requireNonNull(namespace);
+ }
+
+ @Override
+ final @NonNull ClassNamingStrategy fallback() {
+ return new AppendNamespaceNamingStrategy(this);
+ }
+
+ final StatementNamespace namespace() {
+ return namespace;
+ }
+
+ @Override
+ ToStringHelper addToStringAttributes(final ToStringHelper helper) {
+ return helper.add("namespace", namespace);
+ }
+}
import com.google.common.base.MoreObjects.ToStringHelper;
import org.opendaylight.yangtools.yang.common.AbstractQName;
-final class CamelCaseWithNamespaceNamingStrategy extends ClassNamingStrategy {
- private final CamelCaseNamingStrategy delegate;
+final class AppendNamespaceNamingStrategy extends ClassNamingStrategy {
+ private final AbstractNamespacedNamingStrategy delegate;
- CamelCaseWithNamespaceNamingStrategy(final CamelCaseNamingStrategy delegate) {
+ AppendNamespaceNamingStrategy(final AbstractNamespacedNamingStrategy delegate) {
this.delegate = requireNonNull(delegate);
}
import static java.util.Objects.requireNonNull;
import com.google.common.base.MoreObjects.ToStringHelper;
-import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.yangtools.yang.common.AbstractQName;
@NonNullByDefault
-final class CamelCaseNamingStrategy extends ClassNamingStrategy {
- private final StatementNamespace namespace;
+final class CamelCaseNamingStrategy extends AbstractNamespacedNamingStrategy {
private final AbstractQName nodeIdentifier;
CamelCaseNamingStrategy(final StatementNamespace namespace, final AbstractQName nodeIdentifier) {
- this.namespace = requireNonNull(namespace);
+ super(namespace);
this.nodeIdentifier = requireNonNull(nodeIdentifier);
}
return nodeIdentifier;
}
- StatementNamespace namespace() {
- return namespace;
- }
-
- @Override
- @NonNull ClassNamingStrategy fallback() {
- return new CamelCaseWithNamespaceNamingStrategy(this);
- }
-
@Override
ToStringHelper addToStringAttributes(final ToStringHelper helper) {
- return helper.add("localName", nodeIdentifier.getLocalName()).add("namespace", namespace);
+ return super.addToStringAttributes(helper.add("localName", nodeIdentifier.getLocalName()));
}
}