BUG-865: remove yang.model.util.repo 57/26957/3
authorRobert Varga <rovarga@cisco.com>
Mon, 14 Sep 2015 16:10:34 +0000 (18:10 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 16 Sep 2015 14:19:16 +0000 (14:19 +0000)
It has been deprecated in favor of yang.model.repo.utl.

Change-Id: Idae43e14b2853c7f348e016d7d6213acabe6ffc5
Signed-off-by: Robert Varga <rovarga@cisco.com>
15 files changed:
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/AbstractCachingSchemaSourceProvider.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/AdvancedSchemaSourceProvider.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/FilesystemSchemaCachingProvider.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaService.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceProvider.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceProviders.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceTransformation.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SourceIdentifier.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/TransformingSourceProvider.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/package-info.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/URLSchemaContextResolver.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContext.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContextResolver.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromCapabilitiesResolver.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromDependencyInfoResolver.java [deleted file]

diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/AbstractCachingSchemaSourceProvider.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/AbstractCachingSchemaSourceProvider.java
deleted file mode 100644 (file)
index b3a0a4c..0000000
+++ /dev/null
@@ -1,170 +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.model.util.repo;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.concepts.Delegator;
-
-
-/**
- *
- * Abstract caching schema provider with support of multiple context
- * per backing {@link SchemaSourceProvider}.
- *
- * @param <I> Input Schema Source Representation
- * @param <O> Output Schema Source Representation
- *
- * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.util.AbstractSchemaSourceCache}
- */
-@Deprecated
-public abstract class AbstractCachingSchemaSourceProvider<I, O> implements AdvancedSchemaSourceProvider<O>,
-        Delegator<AdvancedSchemaSourceProvider<I>> {
-
-    private final AdvancedSchemaSourceProvider<I> defaultDelegate;
-
-    /**
-     * Construct caching schema source provider with supplied delegate.
-     *
-     * Default delegate is is used to retrieve schema source when cache does not
-     * contain requested sources.
-     *
-     * @param delegate SchemaSourceProvided used to look up and retrieve schema source
-     * when cache does not contain requested sources.
-     */
-    protected AbstractCachingSchemaSourceProvider(final AdvancedSchemaSourceProvider<I> delegate) {
-        this.defaultDelegate = delegate;
-    }
-
-    @Override
-    public Optional<O> getSchemaSource(final String moduleName, final Optional<String> revision) {
-        Preconditions.checkNotNull(moduleName, "Module name should not be null.");
-        Preconditions.checkNotNull(revision, "Revision should not be null");
-        return getSchemaSource(SourceIdentifier.create(moduleName, revision));
-    }
-
-    @Override
-    public Optional<O> getSchemaSource(final SourceIdentifier sourceIdentifier) {
-        return getSchemaSourceImpl(sourceIdentifier, defaultDelegate);
-    }
-
-    /**
-     * Actual implementation of schema source retrieval.
-     *
-     * <ul>
-     * <li>look up cached schema source via {@link #getCachedSchemaSource(SourceIdentifier)}
-     * <li>If source was found in cache, returns source to client code.
-     * <li>If source was not found in cache, Look up schema source in supplied <code>delegate</code>
-     * <li>Updates cache with schema from delegate by {@link #cacheSchemaSource(SourceIdentifier, Optional)}
-     * <li>Result is returned to client code.
-     * </ul>
-     *
-     * @param identifier Source identifier
-     * @param delegate Delegate to lookup if there is a miss.
-     * @return Optional of schema source, present if source was found. Absent otherwise.
-     */
-    protected final Optional<O> getSchemaSourceImpl(final SourceIdentifier identifier,
-            final AdvancedSchemaSourceProvider<I> delegate) {
-        Preconditions.checkNotNull(identifier, "Source identifier name should not be null.");
-
-        Optional<O> cached = getCachedSchemaSource(identifier);
-        if (cached.isPresent()) {
-            return cached;
-        }
-        Optional<I> live = delegate.getSchemaSource(identifier);
-        return cacheSchemaSource(identifier, live);
-    }
-
-    /**
-     * Caches supplied result and returns cached result which should be returned to client.
-     *
-     * <p>
-     * Implementations of cache are required to cache schema source if possible.
-     * They are not required to cache {@link Optional#absent()}.
-     *
-     * Implementations are required to transform source representation if <code>O</code> and <code>I</code>
-     * are different.
-     *
-     * This method SHOULD NOT fail and should recover from Runtime exceptions
-     * by not caching source and only transforming it.
-     *
-     * @param identifier Source Identifier for which schema SHOULD be cached
-     * @param input Optional of schema source, representing one returned from delegate.
-     * @return Optional of schema source, representing result returned from this cache.
-     */
-    protected abstract Optional<O> cacheSchemaSource(SourceIdentifier identifier, Optional<I> input);
-
-    /**
-     * Returns cached schema source of {@link Optional#absent()} if source is not present in cache.
-     *
-     * <p>
-     * Implementations of cache MUST return cached schema source, if it is present in cache,
-     * otherwise source will be requested from deleate and then cache will be updated
-     * via {@link #cacheSchemaSource(SourceIdentifier, Optional)}.
-     *
-     * @param identifier Source Identifier for which schema should be retrieved.
-     * @return Cached schema source.
-     */
-    protected abstract Optional<O> getCachedSchemaSource(SourceIdentifier identifier);
-
-    @Override
-    public AdvancedSchemaSourceProvider<I> getDelegate() {
-        return defaultDelegate;
-    }
-
-    /**
-     * Creates an lightweight instance of source provider, which uses this cache for caching
-     * and supplied additional delegate for lookup of not cached sources.
-     * <p>
-     *
-     * @param delegate Backing {@link SchemaSourceProvider} which should be used for lookup
-     *   for sources not present in schema.
-     * @return new instance of {@link SchemaSourceProvider} which first lookup in cache
-     *   and then in delegate.
-     *
-     */
-    @Beta
-    public SchemaSourceProvider<O> createInstanceFor(final SchemaSourceProvider<I> delegate) {
-        return new SchemaSourceProviderInstance(SchemaSourceProviders.toAdvancedSchemaSourceProvider(delegate));
-
-    }
-
-    /**
-     *
-     * Lightweight instance of source provider, which is associated with parent
-     * {@link AbstractCachingSchemaSourceProvider}, but uses
-     * different delegate for retrieving not cached sources.
-     *
-     */
-    @Beta
-    private class SchemaSourceProviderInstance implements AdvancedSchemaSourceProvider<O>, Delegator<AdvancedSchemaSourceProvider<I>> {
-
-        private final AdvancedSchemaSourceProvider<I> delegate;
-
-        protected SchemaSourceProviderInstance(final AdvancedSchemaSourceProvider<I> delegate) {
-            super();
-            this.delegate = Preconditions.checkNotNull(delegate, "Delegate should not be null");
-        }
-
-        @Override
-        public Optional<O> getSchemaSource(final String moduleName, final Optional<String> revision) {
-            return getSchemaSource(SourceIdentifier.create(moduleName, revision));
-        }
-
-        @Override
-        public AdvancedSchemaSourceProvider<I> getDelegate() {
-            return delegate;
-        }
-
-        @Override
-        public Optional<O> getSchemaSource(final SourceIdentifier sourceIdentifier) {
-            return getSchemaSourceImpl(sourceIdentifier, getDelegate());
-        }
-    }
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/AdvancedSchemaSourceProvider.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/AdvancedSchemaSourceProvider.java
deleted file mode 100644 (file)
index ee34235..0000000
+++ /dev/null
@@ -1,64 +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.model.util.repo;
-
-import com.google.common.base.Optional;
-
-/**
- * Provider of representation of YANG schema sources.
- *
- * <p>
- * {@link AdvancedSchemaSourceProvider} is extension of
- * {@link SchemaSourceProvider} which did not have object concept of source
- * identifier, and introduces {@link SourceIdentifier} (which contains schema
- * name and revision) as identifier of sources.
- *
- * <p>
- * <b>Schema Source representation</b>
- * <p>
- * Representation of schema source. Representation of schema source could exists
- * in various formats (Java types), depending on stage of processing, but
- * representation MUST BE still result of processing of only single unit of schema
- * source (file, input stream). E.g.:
- * <ul>
- * <li>{@link java.lang.String} - textual representation of source code
- * <li>{@link java.io.InputStream} - input stream containing source code
- * <li>{@link com.google.common.io.ByteSource} - source for input streams
- * containing source code
- * <li>Parsed AST - abstract syntax tree, which is result of a parser, but still
- * it is not linked against other schemas.
- * </ul>
- *
- * <p>
- * Conversion between representations should be done via implementations of
- * {@link SchemaSourceTransformation}.
- *
- * @param <T>
- *            Schema source representation type provided by this implementation
- *
- * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider}
- * and related APIs.
- */
-@Deprecated
-public interface AdvancedSchemaSourceProvider<T> extends SchemaSourceProvider<T> {
-
-    /**
-     * Returns representation source for supplied YANG source identifier.
-     *
-     * Returned representation of schema source must be immutable, must not
-     * change during runtime if {@link SourceIdentifier} has specified both
-     * {@link SourceIdentifier#getName()} and
-     * {@link SourceIdentifier#getRevision()}
-     *
-     * @param sourceIdentifier
-     *            source identifier.
-     * @return source representation if supplied YANG module is available
-     *         {@link Optional#absent()} otherwise.
-     */
-    Optional<T> getSchemaSource(SourceIdentifier sourceIdentifier);
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/FilesystemSchemaCachingProvider.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/FilesystemSchemaCachingProvider.java
deleted file mode 100644 (file)
index b676571..0000000
+++ /dev/null
@@ -1,171 +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.model.util.repo;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.util.regex.Pattern;
-import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Filesystem-based schema caching source provider
- *
- * This schema source provider caches all YANG modules loaded from backing
- * schema source providers (registered via
- * {@link #createInstanceFor(SchemaSourceProvider)} to supplied folder.
- *
- * @param <I>
- *            Input format in which schema source is represented.
- *
- * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache}
- *
- */
-@Deprecated
-public final class FilesystemSchemaCachingProvider<I> extends AbstractCachingSchemaSourceProvider<I, InputStream> {
-    private static final Logger LOG = LoggerFactory.getLogger(FilesystemSchemaCachingProvider.class);
-    public static final Pattern REVISION_PATTERN = Pattern.compile("\\d\\d\\d\\d-\\d\\d-\\d\\d");
-
-    private final File storageDirectory;
-    private final SchemaSourceTransformation<I, String> transformationFunction;
-
-    /**
-     *
-     * Construct filesystem caching schema source provider.
-     *
-     *
-     * @param delegate
-     *            Default delegate to lookup for missed entries in cache.
-     * @param directory
-     *            Directory where YANG files should be cached.
-     * @param transformationFunction
-     *            Transformation function which translates from input in format
-     *            <code>I</code> to InputStream.
-     * @throws IllegalArgumentException
-     *             If supplied directory does not exists or is not directory.
-     */
-    public FilesystemSchemaCachingProvider(final AdvancedSchemaSourceProvider<I> delegate, final File directory,
-            final SchemaSourceTransformation<I, String> transformationFunction) {
-        super(delegate);
-        Preconditions.checkNotNull(directory, "directory must not be null.");
-        Preconditions.checkArgument(directory.exists(), "directory must be directory.");
-        Preconditions.checkArgument(directory.isDirectory(), "directory must be directory.");
-        this.storageDirectory = directory;
-        this.transformationFunction = Preconditions.checkNotNull(transformationFunction,
-                "transformationFunction must not be null.");
-    }
-
-    /**
-     *
-     * Construct filesystem caching schema source provider.
-     *
-     *
-     * @param delegate
-     *            Default delegate to lookup for missed entries in cache.
-     * @param directory
-     *            Directory where YANG files should be cached.
-     * @param transformationFunction
-     *            Transformation function which translates from input in format
-     *            <code>I</code> to InputStream.
-     * @throws IllegalArgumentException
-     *             If supplied directory does not exists or is not directory.
-     * @deprecated Use
-     *             {@link #FilesystemSchemaCachingProvider(AdvancedSchemaSourceProvider, File, SchemaSourceTransformation)}
-     *             with
-     *             {@link SchemaSourceProviders#schemaSourceTransformationFrom(Function)}
-     *             instead.
-     */
-    @Deprecated
-    public FilesystemSchemaCachingProvider(final AdvancedSchemaSourceProvider<I> delegate, final File directory,
-            final Function<I, String> transformationFunction) {
-        super(delegate);
-        Preconditions.checkNotNull(directory, "directory must not be null.");
-        Preconditions.checkArgument(directory.exists(), "directory must be directory.");
-        Preconditions.checkArgument(directory.isDirectory(), "directory must be directory.");
-        this.storageDirectory = directory;
-        this.transformationFunction = SchemaSourceProviders.schemaSourceTransformationFrom(transformationFunction);
-    }
-
-    @Override
-    protected synchronized Optional<InputStream> cacheSchemaSource(final SourceIdentifier identifier,
-            final Optional<I> source) {
-        File schemaFile = toFile(identifier);
-        try {
-            if (source.isPresent() && schemaFile.createNewFile()) {
-                try (FileOutputStream outStream = new FileOutputStream(schemaFile);
-                        OutputStreamWriter writer = new OutputStreamWriter(outStream);) {
-                    writer.write(transformToString(source.get()));
-                    writer.flush();
-                } catch (IOException e) {
-                    LOG.warn("Could not chache source for {}. Source: ",identifier,source.get(),e);
-                }
-            }
-        } catch (IOException e) {
-            LOG.warn("Could not create cache file for {}. File: ",identifier,schemaFile,e);
-        }
-        return transformToStream(source);
-    }
-
-    private Optional<InputStream> transformToStream(final Optional<I> source) {
-        if (source.isPresent()) {
-            return Optional.<InputStream> of(new ByteArrayInputStream(transformToString(source.get()).getBytes(
-                    Charsets.UTF_8)));
-        }
-        return Optional.absent();
-    }
-
-    private String transformToString(final I input) {
-        return transformationFunction.transform(input);
-    }
-
-    @Override
-    protected Optional<InputStream> getCachedSchemaSource(final SourceIdentifier identifier) {
-        File inputFile = toFile(identifier);
-        try {
-            if (inputFile.exists() && inputFile.canRead()) {
-                InputStream stream = new FileInputStream(inputFile);
-                return Optional.of(stream);
-            }
-        } catch (FileNotFoundException e) {
-            return Optional.absent();
-        }
-        return Optional.absent();
-    }
-
-    private File toFile(final SourceIdentifier identifier) {
-        return sourceIdToFile(identifier, storageDirectory);
-    }
-
-    public static File sourceIdToFile(final SourceIdentifier identifier, final File storageDirectory) {
-        org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier newIdentifier =
-                org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier.create(identifier.getName(), Optional.fromNullable(identifier.getRevision()));
-        return FilesystemSchemaSourceCache.sourceIdToFile(newIdentifier, storageDirectory);
-    }
-
-    public static FilesystemSchemaCachingProvider<String> createFromStringSourceProvider(
-            final SchemaSourceProvider<String> liveProvider, final File directory) {
-        Preconditions.checkNotNull(liveProvider);
-        Preconditions.checkNotNull(directory);
-        directory.mkdirs();
-        return new FilesystemSchemaCachingProvider<String>(
-                SchemaSourceProviders.toAdvancedSchemaSourceProvider(liveProvider),//
-                directory, //
-                SchemaSourceProviders.<String>identityTransformation());
-    }
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaService.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaService.java
deleted file mode 100644 (file)
index 8804eaa..0000000
+++ /dev/null
@@ -1,25 +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.model.util.repo;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextHolder;
-
-
-/**
- * Represent Schema Service.
- *
- *
- * @deprecated Replaced by {@link SchemaContextHolder}, which provides
- *    component-local view for actual {@link SchemaContext}.
- */
-@Deprecated
-public interface SchemaService {
-
-    SchemaContext getSchemaContext();
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceProvider.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceProvider.java
deleted file mode 100644 (file)
index 8c43f69..0000000
+++ /dev/null
@@ -1,38 +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.model.util.repo;
-
-import com.google.common.base.Optional;
-
-/**
- * Provider of text stream representation of YANG Modules
- *
- * Provider is holder / user implemented service, which
- * may be able to retrieve representation of YANG sources
- * for other components.
- *
- * @param <F> Format in which YANG source is represented.
- * @deprecated Repalced With {@link AdvancedSchemaSourceProvider}
- */
-@Deprecated
-public interface SchemaSourceProvider<F> {
-
-    /**
-     * Returns source for supplied YANG module identifier and revision.
-     *
-     * @param moduleName module name
-     * @param revision revision of module
-     * @return source representation if supplied YANG module is available
-     *  {@link Optional#absent()} otherwise.
-     *  @deprecated Use {@link AdvancedSchemaSourceProvider#getSchemaSource(SourceIdentifier)}
-     *     instead.
-     */
-    @Deprecated
-    Optional<F> getSchemaSource(String moduleName, Optional<String> revision);
-
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceProviders.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceProviders.java
deleted file mode 100644 (file)
index d3ef655..0000000
+++ /dev/null
@@ -1,202 +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.model.util.repo;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import org.opendaylight.yangtools.concepts.Delegator;
-
-/**
- *
- * Utility functions for {@link SchemaSourceProvider}
- *
- *
- * @deprecated Utility classes for deprecated APIs.
- */
-@Deprecated
-public final class SchemaSourceProviders {
-
-    @SuppressWarnings("rawtypes")
-    private static final SchemaSourceProvider NOOP_PROVIDER = new AdvancedSchemaSourceProvider() {
-
-        @Override
-        public Optional getSchemaSource(final String moduleName, final Optional revision) {
-            return Optional.absent();
-        }
-
-        @Override
-        public Optional getSchemaSource(final SourceIdentifier sourceIdentifier) {
-            return Optional.absent();
-        }
-
-    };
-
-    @SuppressWarnings("rawtypes")
-    private static final SchemaSourceTransformation IDENTITY_TRANFORMATION = new IdentityTransformation();
-
-    private static final StringToInputStreamTransformation STRING_TO_INPUTSTREAM_TRANSFORMATION = new StringToInputStreamTransformation();
-
-    private SchemaSourceProviders() {
-        throw new UnsupportedOperationException("Utility class.");
-    }
-
-    /**
-     * Returns a noop schema source provider.
-     *
-     * Noop schema provider returns {@link Optional#absent()} for each call to
-     * query schema source.
-     *
-     * @return A reusable no-operation provider.
-     */
-    @SuppressWarnings("unchecked")
-    public static <T> SchemaSourceProvider<T> noopProvider() {
-        return NOOP_PROVIDER;
-    }
-
-    /**
-     *
-     * Returns delegating schema source provider which returns InputStream from
-     * supplied String based schema source provider.
-     *
-     * @param delegate
-     * @return InputStream-based source provider.
-     */
-    public static SchemaSourceProvider<InputStream> inputStreamProviderfromStringProvider(
-            final AdvancedSchemaSourceProvider<String> delegate) {
-        return TransformingSourceProvider.create(delegate, STRING_TO_INPUTSTREAM_TRANSFORMATION);
-    }
-
-    /**
-     * Returns identity implementation of SchemaSourceTransformation
-     *
-     * Identity implementation of SchemaSourceTransformation is useful
-     * for usecases where Input and Output of SchemaSourceTransformation
-     * are identitcal, and you want to reuse input as an output.
-     *
-     * This implementation is really simple <code>return input;</code>.
-     *
-     * @return Identity transformation.
-     */
-    @SuppressWarnings("unchecked")
-    public static <I> SchemaSourceTransformation<I, I> identityTransformation() {
-        return IDENTITY_TRANFORMATION;
-    }
-
-    public static <I, O> SchemaSourceTransformation<I, O> schemaSourceTransformationFrom(
-            final Function<I, O> transformation) {
-        return new FunctionBasedSchemaSourceTransformation<I, O>(transformation);
-    }
-
-    /**
-     *
-     * Casts {@link SchemaSourceProvider} to
-     * {@link AdvancedSchemaSourceProvider} or wraps it with utility
-     * implementation if supplied delegate does not implement
-     * {@link AdvancedSchemaSourceProvider}.
-     *
-     * @param schemaSourceProvider
-     */
-    public static <O> AdvancedSchemaSourceProvider<O> toAdvancedSchemaSourceProvider(
-            final SchemaSourceProvider<O> schemaSourceProvider) {
-        if (schemaSourceProvider instanceof AdvancedSchemaSourceProvider<?>) {
-            return (AdvancedSchemaSourceProvider<O>) schemaSourceProvider;
-        }
-        return new SchemaSourceCompatibilityWrapper<O>(schemaSourceProvider);
-    }
-
-    private static final class FunctionBasedSchemaSourceTransformation<I, O> implements
-            SchemaSourceTransformation<I, O> {
-
-
-        private final Function<I, O> delegate;
-
-        protected FunctionBasedSchemaSourceTransformation(final Function<I, O> delegate) {
-            super();
-            this.delegate = Preconditions.checkNotNull(delegate, "delegate MUST NOT be null.");
-        }
-
-        @Override
-        public O transform(final I input) {
-            return delegate.apply(input);
-        }
-
-        @Override
-        public String toString() {
-            return "FunctionBasedSchemaSourceTransformation [delegate=" + delegate + "]";
-        }
-    }
-
-    private final static class SchemaSourceCompatibilityWrapper<O> implements //
-            AdvancedSchemaSourceProvider<O>, //
-            Delegator<SchemaSourceProvider<O>> {
-
-        private final SchemaSourceProvider<O> delegate;
-
-        public SchemaSourceCompatibilityWrapper(final SchemaSourceProvider<O> delegate) {
-            this.delegate = delegate;
-        }
-
-        @Override
-        public SchemaSourceProvider<O> getDelegate() {
-            return delegate;
-        }
-
-
-        /*
-         * Deprecation warnings are suppresed, since this implementation
-         * needs to invoke deprecated method in order to provide
-         * implementation of non-deprecated APIs using legacy ones.
-         *
-         * (non-Javadoc)
-         * @see org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider#getSchemaSource(org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier)
-         */
-        @Override
-        public Optional<O> getSchemaSource(final SourceIdentifier sourceIdentifier) {
-
-            final String moduleName = sourceIdentifier.getName();
-            Optional<String> revision = Optional.fromNullable(sourceIdentifier.getRevision());
-            return delegate.getSchemaSource(moduleName, revision);
-        }
-
-        /*
-         * Deprecation warnings are suppresed, since this implementation
-         * needs to invoke deprecated method in order to provide
-         * implementation of non-deprecated APIs using legacy ones.
-         *
-         * (non-Javadoc)
-         * @see org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider#getSchemaSource(org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier)
-         */
-        @Override
-        public Optional<O> getSchemaSource(final String moduleName, final Optional<String> revision) {
-            return delegate.getSchemaSource(moduleName, revision);
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static class  IdentityTransformation implements SchemaSourceTransformation {
-
-        @Override
-        public Object transform(final Object input) {
-            return input;
-        }
-    }
-
-    private static class StringToInputStreamTransformation implements SchemaSourceTransformation<String, InputStream> {
-
-        @Override
-        public InputStream transform(final String input) {
-            return new ByteArrayInputStream(input.getBytes(Charsets.UTF_8));
-        }
-
-    }
-
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceTransformation.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SchemaSourceTransformation.java
deleted file mode 100644 (file)
index 31b43c4..0000000
+++ /dev/null
@@ -1,68 +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.model.util.repo;
-
-import com.google.common.annotations.Beta;
-
-/**
- *
- * Schema Source Transformation which transforms from one schema source
- * representation to another.
- *
- * <p>
- * <b>Representation of Schema Source</b>
- * <p>
- * Schema source may be represented by
- * various Java Types, which depends on provider and/or consumer.
- * <p>
- * E.g example of possible representations:
- * <ul>
- * <li>{@link String}
- * <li>{@link java.io.InputStream}
- * <li>{@link com.google.common.io.ByteSource}
- * </ul>
- *
- * FIXME: <b>Beta:</b> Consider allowing transformations, which may
- * fail to produce Output, this will require introduction of
- * checked exception.
- *
- * @param <I> Input schema source representation
- * @param <O> Output schema source representation
- *
- * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.util.SchemaSourceTransformer}
- */
-@Beta
-@Deprecated
-public interface SchemaSourceTransformation<I, O> {
-
-    /**
-     *
-     * Transforms supplied schema source in format <code>I</code> to schema
-     * source in format <code>O</code>.
-     *
-     * <ul>
-     * <li>Its execution does not cause any observable side effects.
-     * <li>If the contents of a,b are semantically same (e.g. contents of InputStream),
-     * output representations MUST BE also semantically equals.
-     * </ul>
-     *
-     * Implementations of transformation SHOULD NOT fail to
-     * transform valid non-null input to output representation.
-     *
-     *
-     * FIXME: <b>Beta:</b> Consider lowering condition for safe transformation
-     * and introduce checked exception for cases when transformation may fail.
-     *
-     * @param input Not null input which should be transformed
-     * @return Representation of input in <code>O</code> format.
-     * @throws NullPointerException if input is null.
-     *
-     */
-    @Beta
-    O transform(I input);
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SourceIdentifier.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SourceIdentifier.java
deleted file mode 100644 (file)
index 7ae8b6f..0000000
+++ /dev/null
@@ -1,163 +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.model.util.repo;
-
-import com.google.common.base.Optional;
-import org.opendaylight.yangtools.concepts.Immutable;
-
-/**
- *
- * YANG Schema source identifier
- *
- * Simple transfer object represents identifier of source for YANG schema (module or submodule),
- * which consists of
- * <ul>
- * <li>YANG schema name ({@link #getName()}
- * <li>Module revision (optional) ({link {@link #getRevision()})
- * </ul>
- *
- * Source identifier is designated to be carry only necessary information
- * to look-up YANG model source and to be used by {@link AdvancedSchemaSourceProvider}
- * and similar.
- *
- * <b>Note:</b>On source retrieval layer it is impossible to distinguish
- * between YANG module and/or submodule unless source is present.
- *
- * <p>
- * (For further reference see: http://tools.ietf.org/html/rfc6020#section-5.2 and
- * http://tools.ietf.org/html/rfc6022#section-3.1 ).
- *
- *
- * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier}
- */
-@Deprecated
-public final class SourceIdentifier implements Immutable {
-
-    private final String name;
-    private final String revision;
-
-    /**
-     *
-     * Creates new YANG Schema source identifier.
-     *
-     * @param name Name of schema
-     * @param formattedRevision Revision of source in format YYYY-mm-dd
-     */
-    public SourceIdentifier(final String name, final Optional<String> formattedRevision) {
-        super();
-        this.name = name;
-        this.revision = formattedRevision.orNull();
-    }
-
-    /**
-     * Returns model name
-     *
-     * @return model name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Returns revision of source or null if revision was not supplied.
-     *
-     * @return revision of source or null if revision was not supplied.
-     */
-    public String getRevision() {
-        return revision;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((revision == null) ? 0 : revision.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        SourceIdentifier other = (SourceIdentifier) obj;
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
-            return false;
-        }
-        if (revision == null) {
-            if (other.revision != null) {
-                return false;
-            }
-        } else if (!revision.equals(other.revision)) {
-            return false;
-        }
-        return true;
-    }
-
-    public static SourceIdentifier create(final String moduleName, final Optional<String> revision) {
-        return new SourceIdentifier(moduleName, revision);
-    }
-
-    /**
-     * Returns filename for this YANG module as specified in RFC 6020.
-     *
-     * Returns filename in format
-     * <code>name ['@' revision] '.yang'</code>
-     * <p>
-     * Where revision is  date in format YYYY-mm-dd.
-     * <p>
-     * See
-     * http://tools.ietf.org/html/rfc6020#section-5.2
-     *
-     * @return Filename for this source identifier.
-     */
-    public String toYangFilename() {
-        return toYangFileName(name, Optional.fromNullable(revision));
-    }
-
-    @Override
-    public String toString() {
-        return "SourceIdentifier [name=" + name + "@" + revision + "]";
-    }
-
-    /**
-     * Returns filename for this YANG module as specified in RFC 6020.
-     *
-     * Returns filename in format
-     * <code>moduleName ['@' revision] '.yang'</code>
-     *
-     * Where Where revision-date is in format YYYY-mm-dd.
-     *
-     * <p>
-     * See
-     * http://tools.ietf.org/html/rfc6020#section-5.2
-     *
-     * @return Filename for this source identifier.
-     */
-    public static String toYangFileName(final String moduleName, final Optional<String> revision) {
-        StringBuilder filename = new StringBuilder(moduleName);
-        if (revision.isPresent()) {
-            filename.append('@');
-            filename.append(revision.get());
-        }
-        filename.append(".yang");
-        return filename.toString();
-    }
-
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/TransformingSourceProvider.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/TransformingSourceProvider.java
deleted file mode 100644 (file)
index e831273..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2014, 2015 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.repo;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.concepts.Delegator;
-
-/**
- *
- * Utility Source Provider implementation which uses delegate to retrieve
- * sources and transformation function to convert sources to different
- * representation.
- *
- *
- * @param <I>
- *            Representation of schema sources used by delegate
- * @param <O>
- *            Representation of schema sources exposed by this provider
- *
- * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.util.SchemaSourceTransformer}
- */
-@Deprecated
-public final class TransformingSourceProvider<I, O> implements //
-        AdvancedSchemaSourceProvider<O>, Delegator<AdvancedSchemaSourceProvider<I>> {
-
-    private final AdvancedSchemaSourceProvider<I> delegate;
-    private final SchemaSourceTransformation<I, O> transformation;
-
-    /**
-     * Creates instance of transforming schema source provider which uses
-     * supplied delegate to retrieve sources and transformation to change
-     * sources to different representation.
-     *
-     * @param delegate
-     *            Delegate which provides sources.
-     * @param transformation
-     *            Transformation function which converts sources
-     * @return Instance of TransformingSourceProvider
-     * @throws NullPointerException
-     *             if any of arguments is null.
-     */
-    public static <I, O> TransformingSourceProvider<I, O> create(final AdvancedSchemaSourceProvider<I> delegate,
-            final SchemaSourceTransformation<I, O> transformation) {
-        return new TransformingSourceProvider<>(delegate, transformation);
-    }
-
-    private TransformingSourceProvider(final AdvancedSchemaSourceProvider<I> delegate,
-            final SchemaSourceTransformation<I, O> transformation) {
-        this.delegate = Preconditions.checkNotNull(delegate, "delegate must not be null");
-        this.transformation = Preconditions.checkNotNull(transformation, "transformation must not be null");
-    }
-
-    @Override
-    public AdvancedSchemaSourceProvider<I> getDelegate() {
-        return delegate;
-    }
-
-    @Override
-    public Optional<O> getSchemaSource(final SourceIdentifier sourceIdentifier) {
-        Optional<I> potentialSource = getDelegate().getSchemaSource(sourceIdentifier);
-        if (potentialSource.isPresent()) {
-            I inputSource = potentialSource.get();
-            return Optional.<O> of(transformation.transform(inputSource));
-        }
-        return Optional.absent();
-    }
-
-    @Override
-    public Optional<O> getSchemaSource(final String moduleName, final Optional<String> revision) {
-        return getSchemaSource(SourceIdentifier.create(moduleName, revision));
-    }
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/package-info.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/package-info.java
deleted file mode 100644 (file)
index 768ba64..0000000
+++ /dev/null
@@ -1,47 +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
- */
-/**
- * This package introduces concepts, generic interfaces and implementations for
- * creating and working with YANG Schema source repositories and working with them.
- *
- * <h2>Concepts</h2>
- * <dl>
- * <dt>Schema Source</dt>
- * <dd>Source of YANG Schema, which is not processed, not resolved against other schemas
- *    and from contents of <i>Schema Source</i> in combination with other Schema sources
- *    it is possible to create resolved YANG Schema context.
- * </dd>
- * <dt>{@link org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier}</dt>
- * <dd>Identifier of Schema Source. Identifier is not tied with source or representation.</dd>
- * <dt>Schema Source Representation</dt>
- * <dd>Representation of schema source. Representation of schema source could exists in various
- * formats (Java types), depending on stage of processing, but representation MUST BE
- * still result of processing only single unit of schema source (e.g. file, input stream). E.g.:
- * <ul>
- * <li>{@link java.lang.String} - textual representation of source code
- * <li>{@link java.io.InputStream} - input stream containing source code
- * <li>{@link com.google.common.io.ByteSource} - source for input streams containing source code
- * <li>Parsed AST - abstract syntax tree, which is result of a parser, but still it is not linked
- * against other schemas.
- * </ul>
- * </dd>
- * <dt>{@link org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider}</dt>
- * <dd>
- *    Service which provides query API to obtain <i>Schema Source Representation</i> associated
- *    with {@link org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier}.
- * </dd>
- * <dt>{@link org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceTransformation}</dt>
- * <dd>
- * Function (service) which provides transformation from one <i>Schema Source Representation</i>
- * type to another.
- * </dd>
- * </dl>
- *
- *
- */
-package org.opendaylight.yangtools.yang.model.util.repo;
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/URLSchemaContextResolver.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/URLSchemaContextResolver.java
deleted file mode 100644 (file)
index 440df89..0000000
+++ /dev/null
@@ -1,172 +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.parser.impl.util;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.io.ByteSource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated Use {@link org.opendaylight.yangtools.yang.parser.repo.URLSchemaContextResolver}
- * instead.
- */
-@Deprecated
-@ThreadSafe
-public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<InputStream> {
-
-    private static final Logger LOG = LoggerFactory.getLogger(URLSchemaContextResolver.class);
-
-    @GuardedBy("this")
-    private final ConcurrentMap<SourceIdentifier, SourceContext> availableSources = new ConcurrentHashMap<>();
-    @GuardedBy("this")
-    private YangSourceContext currentSourceContext;
-    @GuardedBy("this")
-    private Optional<SchemaContext> currentSchemaContext = Optional.absent();
-
-    /**
-     * Register new yang schema when it appears.
-     * @param source URL of a yang file
-     * @return new instance of SourceContext if the source is not null
-     */
-    public synchronized ObjectRegistration<URL> registerSource(final URL source) {
-        checkArgument(source != null, "Supplied source must not be null");
-        InputStream yangStream = getInputStream(source);
-        YangModelDependencyInfo modelInfo = YangModelDependencyInfo.fromInputStream(yangStream);
-        SourceIdentifier identifier = SourceIdentifier.create(modelInfo.getName(),
-                Optional.of(modelInfo.getFormattedRevision()));
-        SourceContext sourceContext = new SourceContext(source, identifier, modelInfo);
-        availableSources.putIfAbsent(identifier, sourceContext);
-        return sourceContext;
-    }
-
-    public synchronized Optional<SchemaContext> getSchemaContext() {
-        return currentSchemaContext;
-    }
-
-    @Override
-    public synchronized Optional<InputStream> getSchemaSource(final SourceIdentifier key) {
-        SourceContext ctx = availableSources.get(key);
-        if (ctx != null) {
-            InputStream stream = getInputStream(ctx.getInstance());
-            return Optional.fromNullable(stream);
-        }
-        return Optional.absent();
-    }
-
-    @Override
-    public Optional<InputStream> getSchemaSource(final String name, final Optional<String> version) {
-        return getSchemaSource(SourceIdentifier.create(name, version));
-    }
-
-    private static InputStream getInputStream(final URL source) {
-        InputStream stream;
-        try {
-            stream = source.openStream();
-        } catch (IOException e) {
-            throw new IllegalArgumentException("Supplied stream: " + source + " is not available", e);
-        }
-        return stream;
-    }
-
-    private final class SourceContext extends AbstractObjectRegistration<URL>
-            implements Identifiable<SourceIdentifier> {
-
-        final SourceIdentifier identifier;
-        final YangModelDependencyInfo dependencyInfo;
-
-        public SourceContext(final URL instance, final SourceIdentifier identifier, final YangModelDependencyInfo modelInfo) {
-            super(instance);
-            this.identifier = identifier;
-            this.dependencyInfo = modelInfo;
-        }
-
-        @Override
-        public SourceIdentifier getIdentifier() {
-            return identifier;
-        }
-
-        @Override
-        protected void removeRegistration() {
-            removeSource(this);
-        }
-
-        public YangModelDependencyInfo getDependencyInfo() {
-            return dependencyInfo;
-        }
-    }
-
-    private synchronized void removeSource(final SourceContext sourceContext) {
-        boolean removed = availableSources.remove(sourceContext.getIdentifier(), sourceContext);
-        if (removed) {
-            tryToUpdateSchemaContext();
-        }
-    }
-
-    /**
-     * Try to parse all currently available yang files and build new schema context.
-     * @return new schema context iif there is at least 1 yang file registered and new schema context was successfully built.
-     */
-    public synchronized Optional<SchemaContext> tryToUpdateSchemaContext() {
-        if (availableSources.isEmpty()) {
-            return Optional.absent();
-        }
-        ImmutableMap<SourceIdentifier, SourceContext> actualSources = ImmutableMap.copyOf(availableSources);
-        Builder<SourceIdentifier, YangModelDependencyInfo> builder = ImmutableMap.<SourceIdentifier, YangModelDependencyInfo>builder();
-        for (Entry<SourceIdentifier, SourceContext> entry : actualSources.entrySet()) {
-            builder.put(entry.getKey(), entry.getValue().getDependencyInfo());
-        }
-        ImmutableMap<SourceIdentifier, YangModelDependencyInfo> sourcesMap = builder.build();
-        YangSourceContext yangSourceContext = YangSourceContext.createFrom(sourcesMap, this);
-        LOG.debug("Trying to create schema context from {}", sourcesMap.keySet());
-
-        if (!yangSourceContext.getMissingDependencies().isEmpty()) {
-            LOG.debug("Omitting {} because of unresolved dependencies", yangSourceContext.getMissingDependencies().keySet());
-            LOG.debug("Missing model sources for {}", yangSourceContext.getMissingSources());
-        }
-        if (currentSourceContext == null || !yangSourceContext.getValidSources().equals(currentSourceContext.getValidSources())) {
-            try {
-                Collection<ByteSource> byteSources = yangSourceContext.getValidByteSources();
-                YangParserImpl parser = YangParserImpl.getInstance();
-                SchemaContext schemaContext = parser.parseSources(byteSources);
-                currentSchemaContext = Optional.of(schemaContext);
-                currentSourceContext = yangSourceContext;
-                return Optional.of(schemaContext);
-            } catch (Exception e) {
-                LOG.error("Could not create schema context for {} ", yangSourceContext.getValidSources(), e);
-                return Optional.absent();
-            }
-        } else {
-            currentSourceContext = yangSourceContext;
-            return Optional.absent();
-        }
-    }
-}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContext.java
deleted file mode 100644 (file)
index 913824c..0000000
+++ /dev/null
@@ -1,243 +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.parser.impl.util;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.io.ByteSource;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.concurrent.ThreadSafe;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.builder.impl.BuilderUtils;
-
-/**
- *
- * Context of YANG model sources
- *
- * YANG sources context represent information learned about set of model sources
- * which could be derived from dependency information only.
- *
- * Contains following information:
- * <ul>
- * <li>{@link #getValidSources()} - set of {@link SourceIdentifier} which have
- * their dependencies present and are safe to be used by full blown parser.
- * <li>{@link #getMissingSources()} - set of {@link SourceIdentifier} which have
- * been referenced by other YANG sources, but source code for them is missing.
- * <li>{@link #getMissingDependencies()} - map of {@link SourceIdentifier} and
- * their imports for which source codes was not available.
- * </ul>
- *
- * {@link YangSourceContext} may be associated with {@link SchemaSourceProvider}
- * (see {@link #getDelegate()}, which was used for retrieval of sources during
- * context computation.
- *
- * {@link YangSourceContext} may be used as schema source provider to retrieve
- * this sources.
- *
- *
- */
-// FIXME: for some reason this class is Closeable even though close is never called and no resources are leaked
-@Deprecated
-@ThreadSafe
-public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStream>, Closeable,
-        Delegator<AdvancedSchemaSourceProvider<InputStream>> {
-
-    private final ImmutableSet<SourceIdentifier> validSources;
-
-    private final ImmutableSet<SourceIdentifier> missingSources;
-    private final ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependencies;
-    private final AdvancedSchemaSourceProvider<InputStream> sourceProvider;
-    private final AtomicBoolean isClosed = new AtomicBoolean();
-
-    /**
-     * Construct YANG Source Context
-     *
-     * @param validSourcesSet Set of identifiers of valid sources
-     * @param missingSourcesSet Set of identifiers of missing sources
-     * @param missingDependenciesMap Map of identifiers of resolved sources and their missing imports.
-     * @param sourceProvider Source provider which was used for context resolution or
-     *          null if provider was not used.
-     */
-    YangSourceContext(final ImmutableSet<SourceIdentifier> validSourcesSet,
-            final ImmutableSet<SourceIdentifier> missingSourcesSet,
-            final ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependenciesMap,
-            final AdvancedSchemaSourceProvider<InputStream> sourceProvider) {
-        validSources = checkNotNull(validSourcesSet, "Valid source set must not be null");
-        missingSources = checkNotNull(missingSourcesSet, "Missing sources set must not be null");
-        missingDependencies = checkNotNull(missingDependenciesMap, "Missing dependencies map must not be null");
-        this.sourceProvider = checkNotNull(sourceProvider, "Missing sourceProvider");
-    }
-
-    /**
-     * Returns set of valid source identifiers.
-     *
-     * Source identifier is considered valid if it's source
-     * was present during resolution and sources
-     * for all known dependencies was present at the time of creation
-     * of {@link YangSourceContext}.
-     *
-     * @return Set of valid source identifiers.
-     */
-    public ImmutableSet<SourceIdentifier> getValidSources() {
-        return validSources;
-    }
-
-    /**
-     * Returns set of source identifiers, whom sources was not resolved.
-     *
-     * Source is considered missing if the source was not present
-     * during resolution of {@link YangSourceContext}.
-     *
-     * @return Set of missing sources.
-     */
-    public ImmutableSet<SourceIdentifier> getMissingSources() {
-        return missingSources;
-    }
-
-    /**
-     * Returns a multimap of Source Identifier and imports which had missing
-     * sources.
-     *
-     * Maps a source identifier to its imports, which was not resolved
-     * during resolution of this context, so it is unable to fully
-     * processed source identifier.
-     *
-     *
-     * @return Multi-map of source identifier to it's unresolved dependencies.
-     */
-    public ImmutableMultimap<SourceIdentifier, ModuleImport> getMissingDependencies() {
-        return missingDependencies;
-    }
-
-    @Override
-    public Optional<InputStream> getSchemaSource(final String moduleName, final Optional<String> revision) {
-        return getSchemaSource(SourceIdentifier.create(moduleName, revision));
-    }
-
-    @Override
-    public Optional<InputStream> getSchemaSource(final SourceIdentifier sourceIdentifier) {
-        if (validSources.contains(sourceIdentifier)) {
-            return getDelegateChecked().getSchemaSource(sourceIdentifier);
-        }
-        return Optional.absent();
-    }
-
-    private AdvancedSchemaSourceProvider<InputStream> getDelegateChecked() {
-        assertNotClosed();
-        return sourceProvider;
-    }
-
-    @Override
-    public AdvancedSchemaSourceProvider<InputStream> getDelegate() {
-        assertNotClosed();
-        return sourceProvider;
-    }
-
-    private void assertNotClosed() {
-        if (isClosed.get()) {
-            throw new IllegalStateException("Instance already closed");
-        }
-    }
-
-    @Override
-    public void close() {
-        isClosed.set(true);
-    }
-
-    /**
-     * Creates YANG Source context from supplied capabilities and schema source
-     * provider.
-     *
-     * @param capabilities
-     *            Set of QName representing module capabilities,
-     *            {@link QName#getLocalName()} represents
-     *            source name and {@link QName#getRevision()} represents
-     *            revision of source.
-     *
-     * @param schemaSourceProvider
-     *            - {@link SchemaSourceProvider} which should be used to resolve
-     *            sources.
-     * @return YANG source context which describes resolution of capabilities
-     *         and their dependencies
-     *         against supplied schema source provider.
-     */
-    public static YangSourceContext createFrom(final Iterable<QName> capabilities,
-            final SchemaSourceProvider<InputStream> schemaSourceProvider) {
-        YangSourceContextResolver resolver = new YangSourceFromCapabilitiesResolver(capabilities, schemaSourceProvider);
-        return resolver.resolveContext();
-    }
-
-    public static YangSourceContext createFrom(final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies,
-            AdvancedSchemaSourceProvider<InputStream> sourceProvider) {
-        YangSourceFromDependencyInfoResolver resolver = new YangSourceFromDependencyInfoResolver(
-                moduleDependencies, sourceProvider);
-        return resolver.resolveContext();
-    }
-
-    /**
-     * Returns a list of valid input streams from YANG Source Context
-     * using supplied schema source provider.
-     *
-     * @return List of input streams.
-     * @deprecated Use {@link #getValidByteSources()}
-     */
-    @Deprecated
-    public List<InputStream> getValidInputStreams() {
-        return getValidInputStreamsInternal();
-    }
-
-    private List<InputStream> getValidInputStreamsInternal() {
-        assertNotClosed();
-        final Set<SourceIdentifier> sourcesToLoad = new HashSet<>();
-        sourcesToLoad.addAll(this.getValidSources());
-        for (SourceIdentifier source : this.getValidSources()) {
-            if (source.getRevision() != null) {
-                SourceIdentifier sourceWithoutRevision = SourceIdentifier.create(source.getName(),
-                        Optional.<String> absent());
-                sourcesToLoad.remove(sourceWithoutRevision);
-            }
-        }
-
-        ImmutableList.Builder<InputStream> ret = ImmutableList.<InputStream>builder();
-        for (SourceIdentifier sourceIdentifier : sourcesToLoad) {
-            Optional<InputStream> source = sourceProvider.getSchemaSource(sourceIdentifier);
-            ret.add(source.get());
-        }
-        return ret.build();
-    }
-
-
-
-    public Collection<ByteSource> getValidByteSources() throws IOException {
-        List<InputStream> yangModelStreams = getValidInputStreamsInternal();
-        return BuilderUtils.streamsToByteSources(yangModelStreams);
-    }
-
-    @Deprecated
-    public static List<InputStream> getValidInputStreams(final YangSourceContext context) {
-        return context.getValidInputStreams();
-    }
-
-}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContextResolver.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContextResolver.java
deleted file mode 100644 (file)
index cce4d65..0000000
+++ /dev/null
@@ -1,291 +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.parser.impl.util;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import javax.annotation.concurrent.NotThreadSafe;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * Resolution task for YANG Source Context
- *
- * {@link YangSourceContextResolver} and its subclasses are responsible for
- * resolving {@link YangSourceContext} based on provided
- * {@link SchemaSourceProvider} and set of modules to process.
- *
- *
- * <h3>Implementation notes</h3>
- *
- * In order to customize resolution of {@link YangSourceContext} implementators
- * of this class are required to implement following methods:
- * <ul>
- * <li>{@link #getDependencyInfo(SourceIdentifier)} - Retrieval of dependency
- * information</li>
- * <li>{@link #resolveContext()} - Main resolution algorithm
- * <li>
- * </ul>
- *
- * This abstract class provides utility methods for implementators which may be
- * used in {@link #resolveContext()} to create {@link YangSourceContext}:
- * <ul>
- * <li>{@link #resolveSource(SourceIdentifier)} and
- * {@link #resolveSource(String, Optional)} - Tries to resolve state for
- * supplied model identifier and updates internal state. If state was not
- * already resolved for identifier it invokes
- * {@link #getDependencyInfo(SourceIdentifier)} for particular identifier. This
- * method is recursively invoked for all dependencies.</li>
- * <li>{@link #createSourceContext()} - Creates {@link YangSourceContext} based
- * on previous invocations of {@link #resolveSource(SourceIdentifier)} methods.</li>
- * </ul>
- *
- */
-@Deprecated
-@NotThreadSafe
-public abstract class YangSourceContextResolver {
-
-    /**
-     *
-     * State of source code resolution
-     *
-     */
-    public enum ResolutionState {
-        /**
-         *
-         * Source was missing during source resolution
-         *
-         */
-        MISSING_SOURCE,
-        /**
-         *
-         * One or multiple of dependencies of source are missing
-         *
-         */
-        MISSING_DEPENDENCY,
-        /**
-         * Other error ocurred during resolution
-         *
-         */
-        OTHER_ERROR,
-        /**
-         * Source, its dependencies and its transient dependencies
-         * are resolved.
-         *
-         */
-        EVERYTHING_OK,
-    }
-
-    private static final Logger LOG = LoggerFactory.getLogger(YangSourceContextResolver.class);
-    private final Map<SourceIdentifier, YangSourceContextResolver.ResolutionState> alreadyProcessed = new HashMap<>();
-    private final ImmutableSet.Builder<SourceIdentifier> missingSources = ImmutableSet.builder();
-    private final ImmutableMultimap.Builder<SourceIdentifier, ModuleImport> missingDependencies = ImmutableMultimap
-            .builder();
-    private final ImmutableSet.Builder<SourceIdentifier> validSources = ImmutableSet.builder();
-    private final AdvancedSchemaSourceProvider<InputStream> sourceProvider;
-
-    public YangSourceContextResolver(final AdvancedSchemaSourceProvider<InputStream> sourceProvider) {
-        this.sourceProvider = checkNotNull(sourceProvider, "Missing sourceProvider");
-    }
-
-    /**
-     * Resolves {@link YangSourceContext}
-     *
-     * Implementators of this method should invoke
-     * {@link #resolveSource(SourceIdentifier)} for sources which should be
-     * present in {@link YangSourceContext} and {@link #createSourceContext()}
-     * to create resulting {@link YangSourceContext} which will contain state
-     * derived by callbacks to {@link #getDependencyInfo(SourceIdentifier)}.
-     *
-     * @return Resolved {@link YangSourceContext}.
-     */
-    public abstract YangSourceContext resolveContext();
-
-    /**
-     * Returns dependency information for provided identifier
-     *
-     * Implementations are required to:
-     * <ul>
-     * <li>return {@link Optional#absent()} If source code for source is not
-     * present</li>
-     * <li>return same dependency information for multiple invocations of this
-     * method for same source identifier.</li>
-     * <li>return latest available revision if {@link SourceIdentifier} does not
-     * specify revision. If no revision is available {@link Optional#absent()}
-     * MUST be returned.</li>
-     * </ul>
-     *
-     *
-     * Internal state of this object (and resulting {@link YangSourceContext}
-     * will be updated as following:
-     * <ul>
-     * <li>If {@link Optional#absent()} is returned:
-     * <ul>
-     * <li>source will be marked as {@link ResolutionState#MISSING_SOURCE} and
-     * source identifier will be contained in -
-     * {@link YangSourceContext#getMissingSources()}</li>
-     * <li>All sources which imported or included this source will be present in
-     * {@link YangSourceContext#getMissingDependencies()}</li>
-     * </ul>
-     * </li></ul>
-     *
-     *
-     * @param identifier
-     *            Source identifier
-     * @return Dependency Information for {@link SourceIdentifier},
-     *         {@link Optional#absent()} if no source is present.
-     */
-    abstract Optional<YangModelDependencyInfo> getDependencyInfo(SourceIdentifier identifier);
-
-    /**
-     * Return Source provider against which YANG source context was computed
-     *
-     * @return Source provider against which YANG source context was computed or null, if source provider
-     *   is not associated with computation.
-     */
-    public AdvancedSchemaSourceProvider<InputStream> getSourceProvider() {
-        return sourceProvider;
-    }
-
-    /**
-     *
-     * Resolves resolution state for provided name and formated revision
-     *
-     * This method is shorthand for {@link #resolveSource(SourceIdentifier)}
-     * with argument <code>new SourceIdentifier(name, formattedRevision)</code>
-     *
-     * @see #resolveSource(SourceIdentifier)
-     * @param name
-     *            Name of YANG model
-     * @param formattedRevision
-     *            revision of YANG model
-     * @return Resolution context of YANG Source
-     */
-    public final YangSourceContextResolver.ResolutionState resolveSource(final String name,
-            final Optional<String> formattedRevision) {
-        return resolveSource(new SourceIdentifier(name, formattedRevision));
-    }
-
-    /**
-     * Resolves state of source and updates internal state accordingly.
-     *
-     * <p>
-     * Resolves state of source and updates internal state based on resolution.
-     * This method tries to get module dependency info via user implementation
-     * of {@link #getDependencyInfo(SourceIdentifier)} and then is recursively
-     * called for each announced dependency in
-     * {@link YangModelDependencyInfo#getDependencies()}.
-     *
-     * <p>
-     * Resolution state of resolveSource is internally cached and is used in
-     * subsequent resolution of dependent modules and in creation of
-     * YANGSourceContext via {@link #createSourceContext()}.
-     *
-     * <p>
-     * Possible resolution state for sources are:
-     * <ul>
-     * <li>{@link ResolutionState#EVERYTHING_OK} - If sources for module and its
-     * dependencies are available</li>
-     * <li>{@link ResolutionState#MISSING_DEPENDENCY} - If dependency of source
-     * is missing (call to {@link #getDependencyInfo(SourceIdentifier)} for
-     * imported / included model returned returned {@link Optional#absent()}.</li>
-     * <li>{@link ResolutionState#MISSING_SOURCE} - If source is missing. (call
-     * of {@link #getDependencyInfo(SourceIdentifier)} returned
-     * {@link Optional#absent()}.</li>
-     * <li>{@link ResolutionState#OTHER_ERROR} - If other runtime error
-     * prevented resolution of informations.</li>
-     * </ul>
-     *
-     * Note: Multiple invocations of this method returns cached result, since
-     * {@link #getDependencyInfo(SourceIdentifier)} contract requires
-     * implementors to return same information during life of this object.
-     *
-     *
-     * @param identifier
-     *            Source Identifier
-     * @return Returns resolution state for source.
-     */
-    public final YangSourceContextResolver.ResolutionState resolveSource(final SourceIdentifier identifier) {
-
-        if (alreadyProcessed.containsKey(identifier)) {
-            return alreadyProcessed.get(identifier);
-        }
-        LOG.trace("Resolving source: {}", identifier);
-        YangSourceContextResolver.ResolutionState potentialState = YangSourceContextResolver.ResolutionState.EVERYTHING_OK;
-        try {
-            Optional<YangModelDependencyInfo> potentialInfo = getDependencyInfo(identifier);
-            if (potentialInfo.isPresent()) {
-                YangModelDependencyInfo info = potentialInfo.get();
-                checkValidSource(identifier, info);
-                for (ModuleImport dependency : info.getDependencies()) {
-                    LOG.trace("Source: {} Resolving dependency: {}", identifier, dependency);
-                    YangSourceContextResolver.ResolutionState dependencyState = resolveDependency(dependency);
-                    if (dependencyState != YangSourceContextResolver.ResolutionState.EVERYTHING_OK) {
-                        potentialState = YangSourceContextResolver.ResolutionState.MISSING_DEPENDENCY;
-                        missingDependencies.put(identifier, dependency);
-                    }
-                }
-            } else {
-                missingSources.add(identifier);
-                return YangSourceContextResolver.ResolutionState.MISSING_SOURCE;
-            }
-        } catch (Exception e) {
-            potentialState = YangSourceContextResolver.ResolutionState.OTHER_ERROR;
-        }
-        updateResolutionState(identifier, potentialState);
-        return potentialState;
-    }
-
-    private static boolean checkValidSource(final SourceIdentifier identifier, final YangModelDependencyInfo info) {
-        if (!identifier.getName().equals(info.getName())) {
-            LOG.warn("Incorrect model returned. Identifier name was: {}, source contained: {}", identifier.getName(),
-                    info.getName());
-            throw new IllegalStateException("Incorrect source was returned");
-        }
-        return true;
-    }
-
-    private void updateResolutionState(final SourceIdentifier identifier,
-            final YangSourceContextResolver.ResolutionState potentialState) {
-        alreadyProcessed.put(identifier, potentialState);
-        switch (potentialState) {
-        case MISSING_SOURCE:
-            missingSources.add(identifier);
-            break;
-        case EVERYTHING_OK:
-            validSources.add(identifier);
-            break;
-        default:
-            break;
-        }
-    }
-
-    private YangSourceContextResolver.ResolutionState resolveDependency(final ModuleImport dependency) {
-        String name = dependency.getModuleName();
-        Optional<String> formattedRevision = Optional.fromNullable(QName.formattedRevision(dependency.getRevision()));
-        return resolveSource(new SourceIdentifier(name, formattedRevision));
-    }
-
-    protected YangSourceContext createSourceContext() {
-        ImmutableSet<SourceIdentifier> missingSourcesSet = missingSources.build();
-        ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependenciesMap = missingDependencies.build();
-        ImmutableSet<SourceIdentifier> validSourcesSet = validSources.build();
-        return new YangSourceContext(validSourcesSet, missingSourcesSet, missingDependenciesMap, sourceProvider);
-    }
-}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromCapabilitiesResolver.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromCapabilitiesResolver.java
deleted file mode 100644 (file)
index 04f0061..0000000
+++ /dev/null
@@ -1,67 +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.parser.impl.util;
-
-import com.google.common.base.Optional;
-import java.io.InputStream;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProviders;
-import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
-
-/**
- *
- * Source code resolver which resolves Yang Source Context against
- * {@link SchemaSourceProvider} and set of QName which represent capabilities.
- *
- * This source code resolver is useful for components which deals with
- * capability exchange similar to YANG/Netconf specification
- * and there is {@link SchemaSourceProvider} able to retrieve YANG models.
- *
- */
-@Deprecated
-public final class YangSourceFromCapabilitiesResolver extends YangSourceContextResolver {
-
-    private final Iterable<QName> capabilities;
-
-    /**
-     * Construct new {@link YangSourceFromCapabilitiesResolver}.
-     *
-     * @param capabilities Set of QName representing module capabilities, {@link QName#getLocalName()} represents
-     * source name and {@link QName#getRevision()} represents revision of source.
-     *
-     * @param schemaSourceProvider - {@link SchemaSourceProvider} which should be used to resolve sources.
-     */
-    public YangSourceFromCapabilitiesResolver(final Iterable<QName> capabilities,
-            final SchemaSourceProvider<InputStream> schemaSourceProvider) {
-        super(SchemaSourceProviders.toAdvancedSchemaSourceProvider(schemaSourceProvider));
-        this.capabilities = capabilities;
-    }
-
-    @Override
-    public YangSourceContext resolveContext() {
-        for (QName capability : capabilities) {
-            resolveCapability(capability);
-        }
-        return createSourceContext();
-    }
-
-    private void resolveCapability(final QName capability) {
-        super.resolveSource(capability.getLocalName(), Optional.fromNullable(capability.getFormattedRevision()));
-    }
-
-    @Override
-    public Optional<YangModelDependencyInfo> getDependencyInfo(final SourceIdentifier identifier) {
-        Optional<InputStream> source = getSourceProvider().getSchemaSource(identifier);
-        if (source.isPresent()) {
-            return Optional.of(YangModelDependencyInfo.fromInputStream(source.get()));
-        }
-        return Optional.absent();
-    }
-
-}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromDependencyInfoResolver.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromDependencyInfoResolver.java
deleted file mode 100644 (file)
index 96dad45..0000000
+++ /dev/null
@@ -1,68 +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.parser.impl.util;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.annotation.concurrent.NotThreadSafe;
-import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
-
-/**
- * Resolver for YANG Schema Source which is based on DependencyInfo
- *
- * This resolver does not use {@link SchemaSourceProvider} but supplied map
- * of source identifiers and {@link YangModelDependencyInfo} to construct
- * {@link YangSourceContext}.
- *
- */
-@Deprecated
-@NotThreadSafe
-public final class YangSourceFromDependencyInfoResolver extends YangSourceContextResolver {
-
-    private final Map<SourceIdentifier, YangModelDependencyInfo> dependencyInfo;
-
-    public YangSourceFromDependencyInfoResolver(final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies,
-                                                AdvancedSchemaSourceProvider<InputStream> sourceProvider) {
-        super(sourceProvider);
-        dependencyInfo = ImmutableMap.copyOf(moduleDependencies);
-    }
-
-    @Override
-    public Optional<YangModelDependencyInfo> getDependencyInfo(final SourceIdentifier identifier) {
-        if (identifier.getRevision() != null) {
-            return Optional.fromNullable(dependencyInfo.get(identifier));
-        }
-        YangModelDependencyInfo potential = dependencyInfo.get(identifier);
-        if (potential == null) {
-            for (Entry<SourceIdentifier, YangModelDependencyInfo> newPotential : dependencyInfo.entrySet()) {
-                String newPotentialName = newPotential.getKey().getName();
-
-                if (newPotentialName.equals(identifier.getName())) {
-                    String newPotentialRevision = newPotential.getKey().getRevision();
-                    if (potential == null || 1 == newPotentialRevision.compareTo(potential.getFormattedRevision())) {
-                        potential = newPotential.getValue();
-                    }
-                }
-            }
-        }
-        return Optional.fromNullable(potential);
-    }
-
-    @Override
-    public YangSourceContext resolveContext() {
-        for (SourceIdentifier source : dependencyInfo.keySet()) {
-            resolveSource(source);
-        }
-        return createSourceContext();
-    }
-}