*/
package org.opendaylight.yangtools.yang.model.repo.api;
+import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
-import java.util.Map;
+import java.util.Collection;
+import java.util.Collections;
import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+
/**
* Exception thrown when a Schema Source fails to resolve.
*/
-public class SchemaResolutionException extends Exception {
+@Beta
+public class SchemaResolutionException extends SchemaSourceException {
private static final long serialVersionUID = 1L;
- private final Map<SourceIdentifier, Throwable> unresolvedSources;
+ private final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports;
+ private final Collection<SourceIdentifier> resolvedSources;
public SchemaResolutionException(final @Nonnull String message) {
this(message, (Throwable)null);
}
public SchemaResolutionException(final @Nonnull String message, final Throwable cause) {
- this(message, cause, ImmutableMap.<SourceIdentifier, Exception>of());
+ this(message, cause, Collections.<SourceIdentifier>emptySet(), ImmutableMultimap.<SourceIdentifier, ModuleImport>of());
}
- public SchemaResolutionException(final @Nonnull String message, final @Nonnull Map<SourceIdentifier, ? extends Throwable> unresolvedSources) {
- super(Preconditions.checkNotNull(message));
- this.unresolvedSources = ImmutableMap.copyOf(unresolvedSources);
+ public SchemaResolutionException(final @Nonnull String message, final Collection<SourceIdentifier> resolvedSources,
+ final @Nonnull Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
+ this(message, null, Collections.<SourceIdentifier>emptySet(), unsatisfiedImports);
}
- public SchemaResolutionException(final @Nonnull String message, final Throwable cause, @Nonnull final Map<SourceIdentifier, ? extends Throwable> unresolvedSources) {
+ public SchemaResolutionException(final @Nonnull String message, final Throwable cause,
+ @Nonnull final Collection<SourceIdentifier> resolvedSources,
+ @Nonnull final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
super(message, cause);
- this.unresolvedSources = ImmutableMap.copyOf(unresolvedSources);
+ this.unsatisfiedImports = ImmutableMultimap.copyOf(unsatisfiedImports);
+ this.resolvedSources = ImmutableList.copyOf(resolvedSources);
}
/**
*
* @return Source/reason map.
*/
- public final Map<SourceIdentifier, Throwable> getUnresolvedSources() {
- return unresolvedSources;
+ public final Multimap<SourceIdentifier, ModuleImport> getUnsatisfiedImports() {
+ return unsatisfiedImports;
+ }
+
+
+ // FIXME: should be leak actual mapping?
+ public final Collection<SourceIdentifier> getResolvedSources() {
+ return resolvedSources;
}
@Override
public final String toString() {
- return addToStringAttributes(Objects.toStringHelper(this).add("unresolvedSources", unresolvedSources)).toString();
+ return addToStringAttributes(Objects.toStringHelper(this).add("unsatisfiedImports", unsatisfiedImports)).toString();
}
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {