Remove explicit throws of SourceException 72/35872/3
authorRobert Varga <rovarga@cisco.com>
Mon, 7 Mar 2016 12:46:17 +0000 (13:46 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 9 Mar 2016 16:25:21 +0000 (16:25 +0000)
SourceException is a RuntimeException, no need to declared it as thrown
(and Sonar is touchy about it).

Change-Id: Ic27e4bda3642f8e7a3fa8c8ab95a32c05dcc00e6
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-transform/src/main/java/org/opendaylight/yangtools/transform/QNameTransformingStreamWriter.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java

index 7141f8e5ace751d89b238d69f9887df62b25eb08..1ac1fff971168960a62e76318f2940b2eb1610fc 100644 (file)
@@ -99,79 +99,77 @@ public abstract class QNameTransformingStreamWriter extends ForwardingObject imp
     protected abstract @Nonnull QName transform(@Nonnull QName key);
 
     @Override
-    public void leafNode(final NodeIdentifier name, final Object value) throws IOException, IllegalArgumentException {
+    public void leafNode(final NodeIdentifier name, final Object value) throws IOException {
         delegate().leafNode(transform(name), value);
     }
 
     @Override
-    public void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startLeafSet(transform(name), childSizeHint);
     }
 
     @Override
-    public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startOrderedLeafSet(transform(name), childSizeHint);
     }
 
     @Override
-    public void leafSetEntryNode(final QName name, final Object value) throws IOException, IllegalArgumentException {
+    public void leafSetEntryNode(final QName name, final Object value) throws IOException {
         delegate().leafSetEntryNode(transform(name), value);
     }
 
     @Override
-    public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startContainerNode(transform(name), childSizeHint);
     }
 
     @Override
-    public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startUnkeyedList(transform(name), childSizeHint);
     }
 
     @Override
-    public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalStateException {
+    public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startUnkeyedListItem(transform(name), childSizeHint);
     }
 
     @Override
-    public void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startMapNode(transform(name), childSizeHint);
     }
 
     @Override
-    public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint) throws IOException,
-            IllegalArgumentException {
+    public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint) throws IOException {
         delegate().startMapEntryNode(transform(identifier), childSizeHint);
     }
 
     @Override
-    public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException,
-            IllegalArgumentException {
+    public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startOrderedMapNode(transform(name), childSizeHint);
     }
 
     @Override
-    public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startChoiceNode(transform(name), childSizeHint);
     }
 
     @Override
-    public void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException, IllegalArgumentException {
+    public void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
         delegate().startAugmentationNode(transform(identifier));
     }
 
     @Override
-    public void anyxmlNode(final NodeIdentifier name, final Object value) throws IOException, IllegalArgumentException {
+    public void anyxmlNode(final NodeIdentifier name, final Object value) throws IOException {
         delegate().anyxmlNode(transform(name), value);
     }
 
     @Override
-    public void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException {
+    public void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         delegate().startYangModeledAnyXmlNode(transform(name), childSizeHint);
     }
 
     @Override
-    public void endNode() throws IOException, IllegalStateException {
+    public void endNode() throws IOException {
         delegate().endNode();
     }
 
index f224e768c9168b8e086f2cbc76a517ff5002fb4d..e037ae534be63d2b67430e5dbf752213a664813d 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
@@ -94,15 +93,19 @@ public class CrossSourceStatementReactor {
             }
         }
 
-        public EffectiveModelContext build() throws SourceException, ReactorException {
+        /**
+         * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException
+         * @throws ReactorException
+         */
+        public EffectiveModelContext build() throws ReactorException {
             return context.build();
         }
 
-        public EffectiveSchemaContext buildEffective() throws SourceException, ReactorException {
+        public EffectiveSchemaContext buildEffective() throws ReactorException {
             return context.buildEffective();
         }
 
-        public SchemaContext buildEffective(final Collection<ByteSource> yangByteSources) throws SourceException,
+        public SchemaContext buildEffective(final Collection<ByteSource> yangByteSources) throws
                 ReactorException, IOException {
             for (ByteSource yangByteSource : yangByteSources) {
                 addSource(new YangStatementSourceImpl(yangByteSource.openStream()));
@@ -111,7 +114,7 @@ public class CrossSourceStatementReactor {
             return buildEffective();
         }
 
-        public SchemaContext buildEffective(final List<InputStream> yangInputStreams) throws SourceException,
+        public SchemaContext buildEffective(final List<InputStream> yangInputStreams) throws
                 ReactorException {
             for (InputStream yangInputStream : yangInputStreams) {
                 addSource(new YangStatementSourceImpl(yangInputStream));
@@ -124,7 +127,7 @@ public class CrossSourceStatementReactor {
          * @deprecated This method was never used and relies on deprecated module methods.
          */
         @Deprecated
-        public Map<File, Module> buildEffectiveMappedToSource(final List<File> yangFiles) throws SourceException,
+        public Map<File, Module> buildEffectiveMappedToSource(final List<File> yangFiles) throws
                 ReactorException, FileNotFoundException {
             if (yangFiles == null || yangFiles.isEmpty()) {
                 return Collections.emptyMap();
index 8fe42e1323eb596b78c978736cf876f8c8e6cb9c..7520c8ff730e1474094fc0a088205d3dc7bb7414 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Namesp
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 /**
  * root statement class for a Yang source
@@ -28,14 +27,14 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
     private final SourceSpecificContext sourceContext;
     private final A argument;
 
-    RootStatementContext(final ContextBuilder<A, D, E> builder, final SourceSpecificContext sourceContext) throws SourceException {
+    RootStatementContext(final ContextBuilder<A, D, E> builder, final SourceSpecificContext sourceContext) {
         super(builder);
         this.sourceContext = sourceContext;
         this.argument = builder.getDefinition().parseArgumentValue(this, builder.getRawArgument());
     }
 
-    RootStatementContext(final RootStatementContext<A, D, E> original, final QNameModule newQNameModule, final TypeOfCopy typeOfCopy)
-            throws SourceException {
+    RootStatementContext(final RootStatementContext<A, D, E> original, final QNameModule newQNameModule,
+        final TypeOfCopy typeOfCopy) {
         super(original);
 
         sourceContext = original.sourceContext;
@@ -52,10 +51,10 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
      *
      * @param typeOfCopy
      *            determines whether copy is used by augmentation or uses
-     * @throws SourceException
+     * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException
      */
     private void copyDeclaredStmts(final RootStatementContext<A, D, E> original, final QNameModule newQNameModule,
-            final TypeOfCopy typeOfCopy) throws SourceException {
+            final TypeOfCopy typeOfCopy) {
         Collection<? extends StmtContext<?, ?, ?>> originalDeclaredSubstatements = original.declaredSubstatements();
         for (StmtContext<?, ?, ?> stmtContext : originalDeclaredSubstatements) {
             this.addEffectiveSubstatement(stmtContext.createCopy(newQNameModule, this, typeOfCopy));
@@ -67,10 +66,10 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
      *
      * @param typeOfCopy
      *            determines whether copy is used by augmentation or uses
-     * @throws SourceException
+     * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException
      */
     private void copyEffectiveStmts(final RootStatementContext<A, D, E> original, final QNameModule newQNameModule,
-            final TypeOfCopy typeOfCopy) throws SourceException {
+            final TypeOfCopy typeOfCopy) {
         Collection<? extends StmtContext<?, ?, ?>> originalEffectiveSubstatements = original.effectiveSubstatements();
         for (StmtContext<?, ?, ?> stmtContext : originalEffectiveSubstatements) {
             this.addEffectiveSubstatement(stmtContext.createCopy(newQNameModule, this, typeOfCopy));
@@ -125,22 +124,22 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
     /**
      * @return copy of this considering {@link TypeOfCopy} (augment, uses)
      *
-     * @throws SourceException instance of SourceException
+     * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException instance of SourceException
      */
     @Override
-    public StatementContextBase<?, ?, ?> createCopy(final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy)
-            throws SourceException {
+    public StatementContextBase<?, ?, ?> createCopy(final StatementContextBase<?, ?, ?> newParent,
+            final TypeOfCopy typeOfCopy) {
         return createCopy(null, newParent, typeOfCopy);
     }
 
     /**
      * @return copy of this considering {@link TypeOfCopy} (augment, uses)
      *
-     * @throws SourceException instance of SourceException
+     * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException instance of SourceException
      */
     @Override
     public StatementContextBase<A, D, E> createCopy(final QNameModule newQNameModule,
-            final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy) throws SourceException {
+            final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy) {
         RootStatementContext<A, D, E> copy = new RootStatementContext<>(this, newQNameModule, typeOfCopy);
 
         copy.addAllToCopyHistory(this.getCopyHistory());
index 92b2d0bd37c8461dbf6c3ec1412688fe2ed2e9be..5352a62ae1a790f4b3dd528288083e29d74d7b6a 100644 (file)
@@ -45,19 +45,20 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      * event listener when an item is added to model namespace
      */
     interface OnNamespaceItemAdded extends EventListener {
-
-        void namespaceItemAdded(StatementContextBase<?, ?, ?> context, Class<?> namespace, Object key, Object value)
-                throws SourceException;
-
+        /**
+         * @throws SourceException
+         */
+        void namespaceItemAdded(StatementContextBase<?, ?, ?> context, Class<?> namespace, Object key, Object value);
     }
 
     /**
      * event listener when a parsing {@link ModelProcessingPhase} is completed
      */
     interface OnPhaseFinished extends EventListener {
-
-        boolean phaseFinished(StatementContextBase<?, ?, ?> context, ModelProcessingPhase phase) throws SourceException;
-
+        /**
+         * @throws SourceException
+         */
+        boolean phaseFinished(StatementContextBase<?, ?, ?> context, ModelProcessingPhase phase);
     }
 
     /**
@@ -66,7 +67,6 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
     interface ContextMutation {
 
         boolean isFinished();
-
     }
 
     private final StatementDefinitionContext<A, D, E> definition;
@@ -158,7 +158,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
         this.completedPhase = completedPhase;
     }
 
-    StatementContextBase(@Nonnull final ContextBuilder<A, D, E> builder) throws SourceException {
+    StatementContextBase(@Nonnull final ContextBuilder<A, D, E> builder) {
         this.definition = builder.getDefinition();
         this.identifier = builder.createIdentifier();
         this.statementDeclSource = builder.getStamementSource();
@@ -397,7 +397,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      * @throws SourceException
      *             when an error occured in source parsing
      */
-    boolean tryToCompletePhase(final ModelProcessingPhase phase) throws SourceException {
+    boolean tryToCompletePhase(final ModelProcessingPhase phase) {
         Iterator<ContextMutation> openMutations = phaseMutation.get(phase).iterator();
         boolean finished = true;
         while (openMutations.hasNext()) {
@@ -430,7 +430,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      * @throws SourceException
      *             when an error occured in source parsing
      */
-    private void onPhaseCompleted(final ModelProcessingPhase phase) throws SourceException {
+    private void onPhaseCompleted(final ModelProcessingPhase phase) {
         completedPhase = phase;
         Iterator<OnPhaseFinished> listener = phaseListeners.get(completedPhase).iterator();
         while (listener.hasNext()) {
@@ -447,7 +447,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      * @param ref
      * @throws SourceException
      */
-    void endDeclared(final StatementSourceReference ref, final ModelProcessingPhase phase) throws SourceException {
+    void endDeclared(final StatementSourceReference ref, final ModelProcessingPhase phase) {
         definition().onDeclarationFinished(this, phase);
     }
 
@@ -517,7 +517,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      *
      * @throws SourceException
      */
-    void addPhaseCompletedListener(final ModelProcessingPhase phase, final OnPhaseFinished listener) throws SourceException {
+    void addPhaseCompletedListener(final ModelProcessingPhase phase, final OnPhaseFinished listener) {
 
         Preconditions.checkNotNull(phase, "Statement context processing phase cannot be null at: %s",
                 getStatementSourceReference());
index 24cb033571b9192bdcf28b1b1e47f017c24d7e6f..8a6d80a856402fa32045d2b818c599c656adc897 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Regist
 import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.GroupingUtils;
@@ -42,8 +41,7 @@ final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends Eff
     private final A argument;
     private volatile SchemaPath schemaPath;
 
-    SubstatementContext(final StatementContextBase<?, ?, ?> parent,
-            final ContextBuilder<A, D, E> builder) throws SourceException {
+    SubstatementContext(final StatementContextBase<?, ?, ?> parent, final ContextBuilder<A, D, E> builder) {
         super(builder);
         this.parent = Preconditions.checkNotNull(parent, "Parent must not be null");
         this.argument = builder.getDefinition().parseArgumentValue(this, builder.getRawArgument());
@@ -76,8 +74,7 @@ final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends Eff
 
 
     private void copyDeclaredStmts(final SubstatementContext<A, D, E> original,
-            final QNameModule newQNameModule, final TypeOfCopy typeOfCopy)
-            throws SourceException {
+            final QNameModule newQNameModule, final TypeOfCopy typeOfCopy) {
         Collection<? extends StatementContextBase<?, ?, ?>> originalDeclaredSubstatements = original
                 .declaredSubstatements();
         for (StatementContextBase<?, ?, ?> stmtContext : originalDeclaredSubstatements) {
@@ -92,8 +89,7 @@ final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends Eff
     }
 
     private void copyEffectiveStmts(final SubstatementContext<A, D, E> original,
-            final QNameModule newQNameModule, final TypeOfCopy typeOfCopy)
-            throws SourceException {
+            final QNameModule newQNameModule, final TypeOfCopy typeOfCopy) {
         Collection<? extends StatementContextBase<?, ?, ?>> originalEffectiveSubstatements = original
                 .effectiveSubstatements();
         for (StatementContextBase<?, ?, ?> stmtContext : originalEffectiveSubstatements) {
@@ -134,15 +130,13 @@ final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends Eff
 
     @Override
     public StatementContextBase<?, ?, ?> createCopy(
-            final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy)
-            throws SourceException {
+            final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy) {
         return createCopy(null, newParent, typeOfCopy);
     }
 
     @Override
     public StatementContextBase<A, D, E> createCopy(final QNameModule newQNameModule,
-            final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy)
-            throws SourceException {
+            final StatementContextBase<?, ?, ?> newParent, final TypeOfCopy typeOfCopy) {
         SubstatementContext<A, D, E> copy = new SubstatementContext<>(this, newQNameModule, newParent, typeOfCopy);
 
         copy.addAllToCopyHistory(this.getCopyHistory());