1 32 33 package com.jeantessier.dependency; 34 35 import java.util.*; 36 37 public class LinkMaximizer extends VisitorBase { 38 public LinkMaximizer() { 39 super(); 40 } 41 42 public LinkMaximizer(TraversalStrategy strategy) { 43 super(strategy); 44 } 45 46 protected void postprocessClassNode(ClassNode node) { 47 Iterator i = getStrategy().order(node.getOutboundDependencies()).iterator(); 48 while (i.hasNext()) { 49 node.getPackageNode().addDependency((Node) i.next()); 50 } 51 52 super.postprocessClassNode(node); 53 } 54 55 public void visitInboundClassNode(ClassNode node) { 56 node.getPackageNode().addDependency(getCurrentNode()); 57 } 58 59 public void visitOutboundClassNode(ClassNode node) { 60 getCurrentNode().addDependency(node.getPackageNode()); 61 } 62 63 protected void postprocessFeatureNode(FeatureNode node) { 64 Iterator i = getStrategy().order(node.getOutboundDependencies()).iterator(); 65 while (i.hasNext()) { 66 Node outboundNode = (Node) i.next(); 67 node.getClassNode().addDependency(outboundNode); 68 node.getClassNode().getPackageNode().addDependency(outboundNode); 69 } 70 71 super.postprocessFeatureNode(node); 72 } 73 74 public void visitInboundFeatureNode(FeatureNode node) { 75 node.getClassNode().addDependency(getCurrentNode()); 76 node.getClassNode().getPackageNode().addDependency(getCurrentNode()); 77 } 78 79 public void visitOutboundFeatureNode(FeatureNode node) { 80 getCurrentNode().addDependency(node.getClassNode()); 81 getCurrentNode().addDependency(node.getClassNode().getPackageNode()); 82 } 83 } 84 | Popular Tags |