Propagate @Nonnull and @Nullable annotations
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / SchemaResolutionException.java
index 0070cab71fe3d7bcf734060e9bfc4d6e63351d50..bb9618de9ea26300b56cdfb093b76ce0e30ec66c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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/eplv10.html
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 package org.opendaylight.yangtools.yang.model.repo.api;
 
@@ -23,34 +23,53 @@ import org.opendaylight.yangtools.yang.model.api.ModuleImport;
  */
 @Beta
 public class SchemaResolutionException extends SchemaSourceException {
+
     private static final long serialVersionUID = 1L;
+    private final SourceIdentifier failedSource;
     private final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports;
     private final Collection<SourceIdentifier> resolvedSources;
 
     public SchemaResolutionException(@Nonnull final String message) {
-        this(message, (Throwable)null);
+        this(message, null);
     }
 
     public SchemaResolutionException(@Nonnull final String message, final Throwable cause) {
-        this(message, cause, Collections.<SourceIdentifier>emptySet(), ImmutableMultimap.<SourceIdentifier, ModuleImport>of());
+        this(message, null, cause, Collections.emptySet(), ImmutableMultimap.of());
+    }
+
+    public SchemaResolutionException(@Nonnull final String message, final SourceIdentifier failedSource,
+            final Throwable cause) {
+        this(message, failedSource, cause, Collections.emptySet(), ImmutableMultimap.of());
     }
 
     public SchemaResolutionException(@Nonnull final String message, final Collection<SourceIdentifier> resolvedSources,
             final @Nonnull Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
-        this(message, null, resolvedSources, unsatisfiedImports);
+        this(message, null, null, resolvedSources, unsatisfiedImports);
     }
 
-    public SchemaResolutionException(@Nonnull final String message, final Throwable cause,
-            @Nonnull final Collection<SourceIdentifier> resolvedSources,
+    public SchemaResolutionException(@Nonnull final String message, final SourceIdentifier failedSource,
+            final Throwable cause, @Nonnull final Collection<SourceIdentifier> resolvedSources,
             @Nonnull final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
-        super(formatMessage(message, resolvedSources, unsatisfiedImports), cause);
+        super(formatMessage(message, failedSource, resolvedSources, unsatisfiedImports), cause);
+        this.failedSource = failedSource;
         this.unsatisfiedImports = ImmutableMultimap.copyOf(unsatisfiedImports);
         this.resolvedSources = ImmutableList.copyOf(resolvedSources);
     }
 
-    private static final String MESSAGE_BLUEPRINT = "%s, resolved sources: %s, unsatisfied imports: %s";
-    private static String formatMessage(final String message, final Collection<SourceIdentifier> resolvedSources, final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
-        return String.format(MESSAGE_BLUEPRINT, message, resolvedSources, unsatisfiedImports);
+    private static String formatMessage(final String message, final SourceIdentifier failedSource,
+            final Collection<SourceIdentifier> resolvedSources,
+            final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
+        return String.format("%s, failed source: %s, resolved sources: %s, unsatisfied imports: %s", message,
+                failedSource, resolvedSources, unsatisfiedImports);
+    }
+
+    /**
+     * Return YANG schema source identifier consisting of name and revision of the module which caused this exception
+     *
+     * @return YANG schema source identifier
+     */
+    public final SourceIdentifier getFailedSource() {
+        return this.failedSource;
     }
 
     /**