It has been superseded by SourceIdentifier and its concrete subclasses.
Change-Id: I88ae6bd8fae103198ad3caa7957de32f9bbed8e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
+++ /dev/null
-/*
- * Copyright (c) 2013 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.model.api;
-
-import java.util.Optional;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-
-/**
- * Module identifier. This "identifier" is deprecated and is to be removed in 2.0.0.
- * @author Robert Varga
- *
- * @deprecated Use {@link SourceIdentifier} instead.
- */
-@Deprecated
-public interface ModuleIdentifier {
- /**
- * Returns the name of the module which is specified as argument of YANG
- * {@link Module <b><font color="#FF0000">module</font></b>} keyword.
- *
- * @return string with the name of the module
- */
- String getName();
-
- /**
- * Returns the revision date for the module.
- *
- * @return date of the module revision which is specified as argument of
- * YANG {@link Module <b><font color="#339900">revison</font></b>}
- * keyword
- */
- Optional<Revision> getRevision();
-}
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Lists;
import javax.annotation.concurrent.Immutable;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(new TreeMap<>(),
AbstractSchemaContext::createModuleSet);
- ImmutableMap.Builder<ModuleIdentifier, String> identifiersToSourcesBuilder = ImmutableMap.builder();
-
- //preparing map to get all modules with one name but difference in revision
+ // preparing map to get all modules with one name but difference in revision
final TreeMultimap<String, Module> nameToModulesAll = getStringModuleTreeMultimap();
nameToModulesAll.putAll(getStringModuleMap(delegate));
- //in case there is a particular dependancy to view filteredModules/yang models
- //dependancy is checked for module name and imports
+ // in case there is a particular dependancy to view filteredModules/yang models dependancy is checked
+ // for module name and imports
processForRootModules(delegate, rootModules, filteredModulesBuilder);
- //adding additional modules
+ // adding additional modules
processForAdditionalModules(delegate, additionalModuleIds, filteredModulesBuilder);
filteredModulesBuilder.addAll(getImportedModules(
+++ /dev/null
-/*
- * Copyright (c) 2013 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.model.util;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.Beta;
-import java.util.Optional;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
-
-/**
- * ModuleIdentifier that can be used for indexing/searching by name.
- * Name is only non-null attribute.
- * Equality check on namespace and revision is only triggered if they are non-null
- *
- * @deprecated This class will be removed with {@link ModuleIdentifier}
- */
-@Deprecated
-@Beta
-public final class ModuleIdentifierImpl implements ModuleIdentifier {
- private final Revision revision;
- private final String name;
-
- private ModuleIdentifierImpl(final String name, final Optional<Revision> revision) {
- this.name = checkNotNull(name);
- this.revision = revision.orElse(null);
- }
-
- public static ModuleIdentifier create(final String name, final Optional<Revision> revision) {
- return new ModuleIdentifierImpl(name, revision);
- }
-
- @Override
- public Optional<Revision> getRevision() {
- return Optional.ofNullable(revision);
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "ModuleIdentifierImpl{"
- + "name='" + name + '\''
- + ", revision=" + revision
- + '}';
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof ModuleIdentifier)) {
- return false;
- }
-
- ModuleIdentifier other = (ModuleIdentifier) obj;
-
- if (!name.equals(other.getName())) {
- return false;
- }
-
- // only fail if this revision is non-null
- if (getRevision() != null && !getRevision().equals(other.getRevision())) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-}
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypedSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @param context SchemaContext to be examined
* @return Set of ModuleIdentifiers.
*/
- public static Set<ModuleIdentifier> getConstituentModuleIdentifiers(final SchemaContext context) {
- final Set<ModuleIdentifier> ret = new HashSet<>();
+ public static Set<SourceIdentifier> getConstituentModuleIdentifiers(final SchemaContext context) {
+ final Set<SourceIdentifier> ret = new HashSet<>();
for (Module module : context.getModules()) {
ret.add(moduleToIdentifier(module));
return ret;
}
- private static ModuleIdentifier moduleToIdentifier(final Module module) {
- return ModuleIdentifierImpl.create(module.getName(), module.getRevision());
+ private static SourceIdentifier moduleToIdentifier(final Module module) {
+ return RevisionSourceIdentifier.create(module.getName(), module.getRevision());
}
private static SchemaNode findNodeInModule(final Module module, final Iterable<QName> path) {
import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.findFirstDeclaredSubstatement;
import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
-import java.util.Optional;
import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.util.ModuleIdentifierImpl;
import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
stmt.addToNs(BelongsToPrefixToModuleName.class, prefix, belongsToModuleName);
}
- private static ModuleIdentifier getSubmoduleIdentifier(
- final Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt) {
- final Optional<Revision> maybeDate = StmtContextUtils.getLatestRevision(stmt.declaredSubstatements());
- return ModuleIdentifierImpl.create(stmt.getStatementArgument(), maybeDate);
- }
-
@Override
protected SubstatementValidator getSubstatementValidator() {
return SUBSTATEMENT_VALIDATOR;
import java.util.Set;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.util.ModuleIdentifierImpl;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
@Test
public void testBug6961SchemaContext() throws Exception {
final Optional<Revision> revision = Revision.ofNullable("2016-01-01");
- final ModuleIdentifier foo = ModuleIdentifierImpl.create("foo", revision);
- final ModuleIdentifier sub1Foo = ModuleIdentifierImpl.create("sub1-foo", revision);
- final ModuleIdentifier sub2Foo = ModuleIdentifierImpl.create("sub2-foo", revision);
- final ModuleIdentifier bar = ModuleIdentifierImpl.create("bar", revision);
- final ModuleIdentifier sub1Bar = ModuleIdentifierImpl.create("sub1-bar", revision);
- final ModuleIdentifier baz = ModuleIdentifierImpl.create("baz", revision);
- final Set<ModuleIdentifier> testSet = ImmutableSet.of(foo, sub1Foo, sub2Foo, bar, sub1Bar, baz);
+ final SourceIdentifier foo = RevisionSourceIdentifier.create("foo", revision);
+ final SourceIdentifier sub1Foo = RevisionSourceIdentifier.create("sub1-foo", revision);
+ final SourceIdentifier sub2Foo = RevisionSourceIdentifier.create("sub2-foo", revision);
+ final SourceIdentifier bar = RevisionSourceIdentifier.create("bar", revision);
+ final SourceIdentifier sub1Bar = RevisionSourceIdentifier.create("sub1-bar", revision);
+ final SourceIdentifier baz = RevisionSourceIdentifier.create("baz", revision);
+ final Set<SourceIdentifier> testSet = ImmutableSet.of(foo, sub1Foo, sub2Foo, bar, sub1Bar, baz);
final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6961/");
assertNotNull(context);
- final Set<ModuleIdentifier> allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context);
+ final Set<SourceIdentifier> allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context);
assertNotNull(allModuleIdentifiers);
assertEquals(6, allModuleIdentifiers.size());
final SchemaContext schemaContext = SimpleSchemaContext.forModules(context.getModules());
assertNotNull(schemaContext);
- final Set<ModuleIdentifier> allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers(
+ final Set<SourceIdentifier> allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers(
schemaContext);
assertNotNull(allModuleIdentifiersResolved);
assertEquals(6, allModuleIdentifiersResolved.size());