X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Frfc6020%2FModuleStatementSupport.java;h=f66e2b96c067e68fa269307dc0a41ca4d6f78c1d;hb=04fa25a4fe8957f6492618aa9a1e9a4f9af39df4;hp=ea6d565b895288b891582df87ec952ac5d7e319f;hpb=bf405586fc69c3781311cfb8ac19ba93b670ec8d;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java index ea6d565b89..f66e2b96c0 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java @@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020; import static org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.MAX; import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf; - import com.google.common.base.Optional; import java.net.URI; import java.util.Date; @@ -75,31 +74,28 @@ public class ModuleStatementSupport extends } @Override - public String parseArgumentValue(StmtContext ctx, String value) { + public String parseArgumentValue(final StmtContext ctx, final String value) { return value; } @Override - public ModuleStatement createDeclared(StmtContext ctx) { + public ModuleStatement createDeclared(final StmtContext ctx) { return new ModuleStatementImpl(ctx); } @Override public EffectiveStatement createEffective( - StmtContext> ctx) { + final StmtContext> ctx) { return new ModuleEffectiveStatementImpl(ctx); } @Override - public void onLinkageDeclared(Mutable> stmt) - throws SourceException { + public void onLinkageDeclared(final Mutable> stmt) { Optional moduleNs = Optional.fromNullable(firstAttributeOf(stmt.declaredSubstatements(), NamespaceStatement.class)); - if (!moduleNs.isPresent()) { - throw new SourceException(String.format("Namespace of the module [%s] is missing", - stmt.getStatementArgument()), stmt.getStatementSourceReference()); - } + SourceException.throwIf(!moduleNs.isPresent(), stmt.getStatementSourceReference(), + "Namespace of the module [%s] is missing", stmt.getStatementArgument()); Optional revisionDate = Optional.fromNullable(Utils.getLatestRevision(stmt.declaredSubstatements())); if (!revisionDate.isPresent()) { @@ -114,23 +110,20 @@ public class ModuleStatementSupport extends stmt.addContext(ModuleNamespaceForBelongsTo.class, moduleIdentifier.getName(), stmt); stmt.addContext(NamespaceToModule.class, qNameModule, stmt); - String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class); - if (modulePrefix == null) { - throw new SourceException(String.format("Prefix of the module [%s] is missing", - stmt.getStatementArgument()), stmt.getStatementSourceReference()); - } + final String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class); + SourceException.throwIfNull(modulePrefix, stmt.getStatementSourceReference(), + "Prefix of the module [%s] is missing", stmt.getStatementArgument()); stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule); stmt.addToNs(ModuleNameToModuleQName.class, stmt.getStatementArgument(), qNameModule); stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule); stmt.addToNs(ModuleQNameToModuleName.class, qNameModule, stmt.getStatementArgument()); stmt.addToNs(ModuleIdentifierToModuleQName.class, moduleIdentifier, qNameModule); - stmt.addToNs(ImpPrefixToModuleIdentifier.class, modulePrefix, moduleIdentifier); } @Override - public void onFullDefinitionDeclared(Mutable> stmt) throws SourceException { super.onFullDefinitionDeclared(stmt); SUBSTATEMENT_VALIDATOR.validate(stmt);