Added critical fixes for ASTSchemaSource class. 70/10770/1
authorLukas Sedlak <lsedlak@cisco.com>
Thu, 4 Sep 2014 12:32:13 +0000 (14:32 +0200)
committerLukas Sedlak <lsedlak@cisco.com>
Thu, 4 Sep 2014 12:32:13 +0000 (14:32 +0200)
Modified c-tor of ASTSchemaSource class to not check text parameter with NotNull precondition.
Added NotNull preconditions check into apply methods.

Change-Id: I34965c7cd4225340d589aeebf8d22365c4d373e2
Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ASTSchemaSource.java

index 25e08c21d2edc7d74e145b41a09a78e619a17cf9..9a1cd57005b8146029d924c692df3da1ad629067 100644 (file)
@@ -30,19 +30,22 @@ import org.opendaylight.yangtools.yang.parser.impl.util.YangModelDependencyInfo;
 public final class ASTSchemaSource implements SchemaSourceRepresentation {
     public static final Function<ASTSchemaSource, SourceIdentifier> GET_IDENTIFIER = new Function<ASTSchemaSource, SourceIdentifier>() {
         @Override
-        public SourceIdentifier apply(final ASTSchemaSource input) {
+        public SourceIdentifier apply(@Nonnull final ASTSchemaSource input) {
+            Preconditions.checkNotNull(input);
             return input.getIdentifier();
         }
     };
     public static final Function<ASTSchemaSource, YangModelDependencyInfo> GET_DEPINFO = new Function<ASTSchemaSource, YangModelDependencyInfo>() {
         @Override
-        public YangModelDependencyInfo apply(final ASTSchemaSource input) {
+        public YangModelDependencyInfo apply(@Nonnull final ASTSchemaSource input) {
+            Preconditions.checkNotNull(input);
             return input.getDependencyInformation();
         }
     };
     public static final Function<ASTSchemaSource, ParserRuleContext> GET_AST = new Function<ASTSchemaSource, ParserRuleContext>() {
         @Override
-        public ParserRuleContext apply(final ASTSchemaSource input) {
+        public ParserRuleContext apply(@Nonnull final ASTSchemaSource input) {
+            Preconditions.checkNotNull(input);
             return input.getAST();
         }
     };
@@ -52,11 +55,11 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
     private final SourceIdentifier id;
     private final String text;
 
-    private ASTSchemaSource(final @Nonnull SourceIdentifier id, @Nonnull final ParserRuleContext tree, final @Nonnull YangModelDependencyInfo depInfo, final @Nonnull String text) {
+    private ASTSchemaSource(final @Nonnull SourceIdentifier id, @Nonnull final ParserRuleContext tree, final @Nonnull YangModelDependencyInfo depInfo, final String text) {
         this.depInfo = Preconditions.checkNotNull(depInfo);
         this.tree = Preconditions.checkNotNull(tree);
         this.id = Preconditions.checkNotNull(id);
-        this.text = Preconditions.checkNotNull(text);
+        this.text = text;
     }
 
     /**