Module: BiteScript::Annotatable

Included in:
ClassBuilder, MethodBuilder
Defined in:
lib/bitescript/builder.rb

Instance Method Summary collapse

Instance Method Details

#annotate(cls, runtime = nil) {|annotation| ... } ⇒ Object

Yields:

  • (annotation)


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/bitescript/builder.rb', line 64

def annotate(cls, runtime=nil)
  if Java::JavaClass === cls
    java_class = cls
  else
    java_class = cls.java_class
  end
  
  if runtime.nil?
    retention = java_class.annotation(Retention.java_class)
    return if retention && retention.value.name == 'CLASS'
    runtime = retention && retention.value.name == 'RUNTIME'
  end

  annotation = visit_annotation(Signature.ci(java_class), runtime)
  annotation.extend AnnotationBuilder

  yield annotation
  annotation.visit_end
end