Class: JavaClass::Dependencies::ClasspathNode

Inherits:
Node
  • Object
show all
Defined in:
lib/javaclass/dependencies/classpath_node.rb

Overview

A concrete Node which contains a Classpath and its dependencies. This models a Node as a component, maybe an Eclipse plugin, a Maven module or a library. Dependencies (Edge) contain all references imported by any class of this component.

Author

Peter Kofler

Instance Attribute Summary

Attributes inherited from Node

#dependencies, #name, #size

Instance Method Summary collapse

Methods inherited from Node

#<=>, #==, #add_dependencies, #add_dependency, #each_dependency_provider, #each_edge, #hash, #to_s

Constructor Details

#initialize(name, classpath) ⇒ ClasspathNode

Returns a new instance of ClasspathNode.



13
14
15
16
# File 'lib/javaclass/dependencies/classpath_node.rb', line 13

def initialize(name, classpath)
  super(name, classpath.count)
  @classpath = classpath
end

Instance Method Details

#outgoing_dependenciesObject

Iterate on a list of Edge dependencies this node has.



19
20
21
22
23
24
25
26
27
# File 'lib/javaclass/dependencies/classpath_node.rb', line 19

def outgoing_dependencies
  @classpath.values.each do |clazz|
    clazz.imported_3rd_party_types.each do |import|
      unless satisfies?(import) 
        yield Edge.new(clazz.to_classname, import)
      end
    end
  end
end

#satisfies?(dependency_name) ⇒ Boolean

Does this Node satisfy the dependency dependency_name .

Returns:

  • (Boolean)


30
31
32
# File 'lib/javaclass/dependencies/classpath_node.rb', line 30

def satisfies?(dependency_name)
  @classpath.includes?(dependency_name)
end