2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.repo;
10 import java.util.Collection;
12 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
13 import org.opendaylight.yangtools.yang.model.api.source.SourceDependency;
14 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
15 import org.opendaylight.yangtools.yang.model.spi.source.SourceInfo;
16 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
18 final class RevisionDependencyResolver extends DependencyResolver {
19 RevisionDependencyResolver(final Map<SourceIdentifier, SourceInfo> depInfo) {
24 YangParserConfiguration parserConfig() {
25 return YangParserConfiguration.DEFAULT;
29 boolean isKnown(final Collection<SourceIdentifier> haystack, final SourceDependency dependency) {
31 return haystack.contains(new SourceIdentifier(dependency.name(), dependency.revision()))
32 // Slow revision-less walk
33 || dependency.revision() == null && findWildcard(haystack, dependency.name()) != null;
36 private static SourceIdentifier findWildcard(final Collection<SourceIdentifier> haystack,
37 final Unqualified needle) {
38 for (var sourceId : haystack) {
39 if (needle.equals(sourceId.name())) {