From 7baa44731c56aa2a81ab6386929378c3c6fa6748 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 5 Oct 2023 15:03:43 +0200 Subject: [PATCH] Remove AbstractStringIdentityrefCodec and its subclasses These classes are not used anywhere, remove them. Change-Id: I56f257874c422ac33e0f37608e694c90fb7f4729 Signed-off-by: Robert Varga --- .../AbstractModuleStringIdentityrefCodec.java | 43 ----------------- .../util/AbstractStringIdentityrefCodec.java | 30 ------------ .../util/ModuleStringIdentityrefCodec.java | 48 ------------------- 3 files changed, 121 deletions(-) delete mode 100644 data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractModuleStringIdentityrefCodec.java delete mode 100644 data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractStringIdentityrefCodec.java delete mode 100644 data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ModuleStringIdentityrefCodec.java diff --git a/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractModuleStringIdentityrefCodec.java b/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractModuleStringIdentityrefCodec.java deleted file mode 100644 index d2de311553..0000000000 --- a/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractModuleStringIdentityrefCodec.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. 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.yangtools.yang.data.util; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.annotations.Beta; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; - -@Beta -public abstract class AbstractModuleStringIdentityrefCodec extends AbstractStringIdentityrefCodec { - /** - * Resolve a string prefix into the corresponding module. - * - * @param prefix Prefix - * @return module mapped to prefix, or null if the module cannot be resolved - */ - protected abstract @Nullable Module moduleForPrefix(@NonNull String prefix); - - @Override - protected final QName createQName(final String prefix, final String localName) { - final Module module = moduleForPrefix(prefix); - checkArgument(module != null, "Failed to lookup prefix %s", prefix); - - final QName qname = QName.create(module.getQNameModule(), localName); - for (IdentitySchemaNode identity : module.getIdentities()) { - if (qname.equals(identity.getQName())) { - return identity.getQName(); - } - } - - throw new IllegalArgumentException("Failed to find identity matching " + qname); - } -} diff --git a/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractStringIdentityrefCodec.java b/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractStringIdentityrefCodec.java deleted file mode 100644 index 0f8a852839..0000000000 --- a/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractStringIdentityrefCodec.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. 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.yangtools.yang.data.util; - -import com.google.common.annotations.Beta; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.codec.IdentityrefCodec; - -/** - * Abstract utility class for representations which encode Identityref as a - * prefix:name tuple. Typical uses are RESTCONF/JSON (module:name) and XML (prefix:name). - */ -@Beta -public abstract class AbstractStringIdentityrefCodec extends AbstractNamespaceCodec - implements IdentityrefCodec { - @Override - protected final String serializeImpl(final QName data) { - return appendQName(new StringBuilder(), data).toString(); - } - - @Override - protected final QName deserializeImpl(final String data) { - return parseQName(data); - } -} diff --git a/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ModuleStringIdentityrefCodec.java b/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ModuleStringIdentityrefCodec.java deleted file mode 100644 index d331ff4884..0000000000 --- a/data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ModuleStringIdentityrefCodec.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016 Intel Corporation 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.yangtools.yang.data.util; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.Beta; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.common.XMLNamespace; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider; - -/** - * Base class for implementing identityref codecs on based on module names. - */ -@Beta -public abstract class ModuleStringIdentityrefCodec extends AbstractModuleStringIdentityrefCodec - implements EffectiveModelContextProvider { - private final @NonNull EffectiveModelContext context; - private final @NonNull QNameModule parentModule; - - protected ModuleStringIdentityrefCodec(final @NonNull EffectiveModelContext context, - final @NonNull QNameModule parentModule) { - this.context = requireNonNull(context); - this.parentModule = requireNonNull(parentModule); - } - - @Override - public final EffectiveModelContext getEffectiveModelContext() { - return context; - } - - protected final QNameModule getParentModule() { - return parentModule; - } - - @Override - protected String prefixForNamespace(final XMLNamespace namespace) { - final var modules = context.findModuleStatements(namespace).iterator(); - return modules.hasNext() ? modules.next().argument().getLocalName() : null; - } -} -- 2.36.6