Efetua a busca da Annotation dentro de um objeto retornando uma lista contendo o(s) nome(s) do(s) método(s) onde a mesma foi encontrada.
Sintaxe
Reflection.getMethodsByAnnotation( oObj,cAnnotationName )
Parâmetros Nome
Tipo
Descrição
Obrigatório
Referência
oObj objeto
Objeto na qual a busca será realizada
X
cAnnotationName caractere Nome da Annotation a ser procurada X
Retorno Nome
Tipo
Descrição
aRet
Array
Array contendo os métodos que possuem a Annotation solicitada. Caso não encontre a array retorna vazia.
Exemplo
#include "tlpp-core.th"
@annotation AnnotationGetMethodsByAnnotation
property1 as char
@end
Class GetMethodsByAnnotation
Public Method New()
@AnnotationGetMethodsByAnnotation(property1 = "Method Annotation")
Public Method MethodWithAnnotation()
@AnnotationGetMethodsByAnnotation(property1 = "Method Annotation")
Public Method AnotherMethodWithAnnotation()
EndClass
Method New() class GetMethodsByAnnotation
Return Self
Method MethodWithAnnotation() class GetMethodsByAnnotation
Return
Method AnotherMethodWithAnnotation() class GetMethodsByAnnotation
Return
Function u_testGetMethodsByAnnotation()
Local aRet := {} as array
Local oObj
oObj := GetMethodsByAnnotation():New()
aRet := Reflection.getMethodsByAnnotation(oObj, "AnnotationGetMethodsByAnnotation")
if(valType(aRet) == "A" .and. len(aRet) > 0)
aEval(aRet,{|x| Conout(x)} )
else
Conout('Nao foi encontrada Annotation com os parametros solicitados')
endIf
Return
Resultado do Exemplo ANOTHERMETHODWITHANNOTATION METHODWITHANNOTATION
Abrangência 17.3.0.3
Veja também