Stop calling get on a possible absent value. 46/21646/2
authorTomas Cere <tcere@cisco.com>
Tue, 2 Jun 2015 12:03:58 +0000 (14:03 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 4 Jun 2015 11:02:02 +0000 (11:02 +0000)
Change-Id: I76cc4d6decd7cf65f988dcb87553b280aab21b24
Signed-off-by: Tomas Cere <tcere@cisco.com>
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/ModuleInfoBackedContext.java

index 2ce4b1b5dda31cef014ff66d47cca18b9ceb6fa4..eaf5ff9508ec0d18c90ac52b16cfc29851221f4d 100644 (file)
@@ -175,6 +175,11 @@ public class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy //
 
     @Override
     public SchemaContext getSchemaContext() {
-        return tryToCreateSchemaContext().get();
+        final Optional<SchemaContext> contextOptional = tryToCreateSchemaContext();
+        if (contextOptional.isPresent()) {
+            return contextOptional.get();
+
+        }
+        throw new IllegalStateException("Unable to recreate SchemaContext, error while parsing");
     }
 }