X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Frfc6020%2FGroupingUtils.java;h=c1194deec5e3749eeebd0627a2a5f811252e681b;hb=5c3e87d88694d9f0bbb2ab872b4e68c7d6823dd3;hp=f5a996dbe099fb2156004a0108534824ac31b4a8;hpb=beaf8f16074af36d2e822bbd3fc60d7a5ca66b98;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java index f5a996dbe0..c1194deec5 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java @@ -21,8 +21,8 @@ import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement; import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement; import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement; 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.meta.StmtContext.Mutable; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase; @@ -36,27 +36,22 @@ public final class GroupingUtils { * @param targetCtx * @throws SourceException */ - public static void copyFromSourceToTarget( - StatementContextBase sourceGrpStmtCtx, + public static void copyFromSourceToTarget(StatementContextBase sourceGrpStmtCtx, StatementContextBase targetCtx) throws SourceException { - QNameModule newQNameModule = getNewQNameModule(targetCtx, - sourceGrpStmtCtx); + QNameModule newQNameModule = getNewQNameModule(targetCtx, sourceGrpStmtCtx); copyDeclaredStmts(sourceGrpStmtCtx, targetCtx, newQNameModule); copyEffectiveStmts(sourceGrpStmtCtx, targetCtx, newQNameModule); } - public static void copyDeclaredStmts( - StatementContextBase sourceGrpStmtCtx, - StatementContextBase targetCtx, QNameModule newQNameModule) - throws SourceException { + public static void copyDeclaredStmts(StatementContextBase sourceGrpStmtCtx, + StatementContextBase targetCtx, QNameModule newQNameModule) throws SourceException { Collection> declaredSubstatements = sourceGrpStmtCtx .declaredSubstatements(); for (StatementContextBase originalStmtCtx : declaredSubstatements) { if (needToCopyByUses(originalStmtCtx)) { - StatementContextBase copy = originalStmtCtx - .createCopy(newQNameModule, targetCtx); + StatementContextBase copy = originalStmtCtx.createCopy(newQNameModule, targetCtx); targetCtx.addEffectiveSubstatement(copy); } else if (isReusedByUses(originalStmtCtx)) { targetCtx.addEffectiveSubstatement(originalStmtCtx); @@ -64,16 +59,13 @@ public final class GroupingUtils { } } - public static void copyEffectiveStmts( - StatementContextBase sourceGrpStmtCtx, - StatementContextBase targetCtx, QNameModule newQNameModule) - throws SourceException { + public static void copyEffectiveStmts(StatementContextBase sourceGrpStmtCtx, + StatementContextBase targetCtx, QNameModule newQNameModule) throws SourceException { Collection> effectiveSubstatements = sourceGrpStmtCtx .effectiveSubstatements(); for (StatementContextBase originalStmtCtx : effectiveSubstatements) { if (needToCopyByUses(originalStmtCtx)) { - StatementContextBase copy = originalStmtCtx - .createCopy(newQNameModule, targetCtx); + StatementContextBase copy = originalStmtCtx.createCopy(newQNameModule, targetCtx); targetCtx.addEffectiveSubstatement(copy); } else if (isReusedByUses(originalStmtCtx)) { targetCtx.addEffectiveSubstatement(originalStmtCtx); @@ -81,14 +73,12 @@ public final class GroupingUtils { } } - public static QNameModule getNewQNameModule( - StatementContextBase targetCtx, + public static QNameModule getNewQNameModule(StatementContextBase targetCtx, StmtContext stmtContext) { if (needToCreateNewQName(stmtContext.getPublicDefinition())) { Object targetStmtArgument = targetCtx.getStatementArgument(); Object sourceStmtArgument = stmtContext.getStatementArgument(); - if (targetStmtArgument instanceof QName - && sourceStmtArgument instanceof QName) { + if (targetStmtArgument instanceof QName && sourceStmtArgument instanceof QName) { QName targetQName = (QName) targetStmtArgument; QNameModule targetQNameModule = targetQName.getModule(); @@ -97,8 +87,7 @@ public final class GroupingUtils { if (targetQNameModule.equals(sourceQNameModule)) { return null; - } - else { + } else { return targetQNameModule; } } else { @@ -109,8 +98,7 @@ public final class GroupingUtils { } } - public static boolean needToCreateNewQName( - StatementDefinition publicDefinition) { + public static boolean needToCreateNewQName(StatementDefinition publicDefinition) { return true; } @@ -120,7 +108,7 @@ public final class GroupingUtils { noCopyDefSet.add(Rfc6020Mapping.USES); StatementDefinition def = stmtContext.getPublicDefinition(); - return (!noCopyDefSet.contains(def)); + return !noCopyDefSet.contains(def); } public static boolean isReusedByUses(StmtContext stmtContext) { @@ -129,29 +117,23 @@ public final class GroupingUtils { reusedDefSet.add(Rfc6020Mapping.TYPEDEF); StatementDefinition def = stmtContext.getPublicDefinition(); - return (reusedDefSet.contains(def)); + return reusedDefSet.contains(def); } public static void resolveUsesNode( Mutable> usesNode, - StatementContextBase targetNodeStmtCtx) - throws SourceException { + StatementContextBase targetNodeStmtCtx) throws SourceException { - Collection> declaredSubstatements = usesNode - .declaredSubstatements(); + Collection> declaredSubstatements = usesNode.declaredSubstatements(); for (StatementContextBase subStmtCtx : declaredSubstatements) { - if (StmtContextUtils.producesDeclared(subStmtCtx, - WhenStatement.class)) { - StatementContextBase copy = subStmtCtx.createCopy( - null, targetNodeStmtCtx); + if (StmtContextUtils.producesDeclared(subStmtCtx, WhenStatement.class)) { + StatementContextBase copy = subStmtCtx.createCopy(null, targetNodeStmtCtx); targetNodeStmtCtx.addEffectiveSubstatement(copy); } - if (StmtContextUtils.producesDeclared(subStmtCtx, - RefineStatement.class)) { + if (StmtContextUtils.producesDeclared(subStmtCtx, RefineStatement.class)) { // :TODO resolve and perform refine statement } - if (StmtContextUtils.producesDeclared(subStmtCtx, - AugmentStatement.class)) { + if (StmtContextUtils.producesDeclared(subStmtCtx, AugmentStatement.class)) { // :TODO find target node and perform augmentation } // :TODO resolve other uses substatements