1 32 33 package com.jeantessier.dependency; 34 35 import java.util.*; 36 37 public class ClassNode extends Node { 38 private PackageNode parent; 39 private Collection features = new HashSet(); 40 41 public ClassNode(PackageNode parent, String name, boolean concrete) { 42 super(name, concrete); 43 this.parent = parent; 44 } 45 46 void setConfirmed(boolean confirmed) { 48 if (!confirmed) { 49 Iterator i = getFeatures().iterator(); 50 while (i.hasNext()) { 51 ((Node) i.next()).setConfirmed(false); 52 } 53 } 54 55 super.setConfirmed(confirmed); 56 getPackageNode().setConfirmed(confirmed); 57 } 58 59 public PackageNode getPackageNode() { 60 return parent; 61 } 62 63 public void addFeature(FeatureNode node) { 64 features.add(node); 65 } 66 67 public void removeFeature(FeatureNode node) { 68 features.remove(node); 69 } 70 71 public Collection getFeatures() { 72 return Collections.unmodifiableCollection(features); 73 } 74 75 public boolean canAddDependencyTo(Node node) { 76 return super.canAddDependencyTo(node) && getPackageNode().canAddDependencyTo(node); 77 } 78 79 public void accept(Visitor visitor) { 80 visitor.visitClassNode(this); 81 } 82 83 public void acceptInbound(Visitor visitor) { 84 visitor.visitInboundClassNode(this); 85 } 86 87 public void acceptOutbound(Visitor visitor) { 88 visitor.visitOutboundClassNode(this); 89 } 90 } 91 | Popular Tags |