Method: BiteScript::Annotatable#find_retention

Defined in:
lib/bitescript/builder.rb,
lib/bitescript/asm3/builder.rb

#find_retention(cls) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/bitescript/builder.rb', line 78

def find_retention(cls)
  if cls.kind_of?(BiteScript::ASM::ClassMirror)
    retention = cls.getDeclaredAnnotation('java.lang.annotation.Retention')
  elsif cls.kind_of?(BiteScript::ASM::Type)
    mirror = BiteScript::ASM::ClassMirror.for_name(cls.class_name) rescue nil
    return find_retention(mirror) if mirror
  elsif Java::JavaClass === cls
    retention = cls.annotation(Retention.java_class)
  else
    retention = cls.java_class.annotation(Retention.java_class)
  end
  return 'CLASS' if retention.nil?
  return retention.value.name
end