/** * Utility function to create a textual node ID for a given node. * * @param node * The node to create the ID for * @return The created ID */ protected static String createNodeId(final DependencyGraphNode<?> node) { return AbstractDependencyGraphFormatter.createNodeId(node.getId()); }
/** * Adds an incoming dependency to this node. * * @param source * The source of the dependency. * @param isAssumed * Whether the dependency is assumed or not. * @param origin * The origin of the destination. * @param originPolicy * The origin policy of the destination. */ public void addIncomingDependency(final DependencyGraphNode<T> source, final boolean isAssumed, final TraceInformation origin, final IOriginRetentionPolicy originPolicy) { synchronized (this) { final Map<Integer, WeightedBidirectionalDependencyGraphEdge<T>> relevantDependencies = // NOPMD(UseConcurrentHashMap) isAssumed ? this.assumedIncomingDependencies : this.incomingDependencies; // NOCS (inline ?) WeightedBidirectionalDependencyGraphEdge<T> e = relevantDependencies.get(source.getId()); if (e == null) { e = new WeightedBidirectionalDependencyGraphEdge<T>(this, source, origin, originPolicy); relevantDependencies.put(source.getId(), e); } else { originPolicy.handleOrigin(e, origin); } e.getSourceWeight().incrementAndGet(); } }
/** * Adds an outgoing dependency to this node. * * @param destination * The destination of the dependency. * @param isAssumed * Whether the dependency is assumed or not. * @param origin * The origin of the destination. * @param originPolicy * The origin policy of the destination. */ public void addOutgoingDependency(final DependencyGraphNode<T> destination, final boolean isAssumed, final TraceInformation origin, final IOriginRetentionPolicy originPolicy) { synchronized (this) { final Map<Integer, WeightedBidirectionalDependencyGraphEdge<T>> relevantDependencies = // NOPMD(UseConcurrentHashMap) isAssumed ? this.assumedOutgoingDependencies : this.outgoingDependencies; // NOCS (inline ?) WeightedBidirectionalDependencyGraphEdge<T> e = relevantDependencies.get(destination.getId()); if (e == null) { e = new WeightedBidirectionalDependencyGraphEdge<T>(this, destination, origin, originPolicy); if (isAssumed) { e.setAssumed(); } relevantDependencies.put(destination.getId(), e); } else { originPolicy.handleOrigin(e, origin); } e.getTargetWeight().incrementAndGet(); } }