Class: Java::Annotatable

Inherits:
Object
  • Object
show all
Defined in:
lib/java_dissassembler/annotatable.rb

Direct Known Subclasses

Class, Field, Method

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(annotations) ⇒ Annotatable

Returns a new instance of Annotatable.



4
5
6
# File 'lib/java_dissassembler/annotatable.rb', line 4

def initialize(annotations)
  @annotations = annotations
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



3
4
5
# File 'lib/java_dissassembler/annotatable.rb', line 3

def annotations
  @annotations
end

Instance Method Details

#get_annotation(annotation_name) ⇒ Object



12
13
14
15
# File 'lib/java_dissassembler/annotatable.rb', line 12

def get_annotation(annotation_name)
  hash = @annotations.find { |a| a.keys.include?(annotation_name) }
  hash[annotation_name] unless hash.nil?
end

#has_annotation?(annotation_name) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/java_dissassembler/annotatable.rb', line 8

def has_annotation?(annotation_name)
  @annotations.any? { |hash| hash.keys.any? { |key| key == annotation_name } }
end