Efetua busca da Annotation em um objeto e retorna uma array com o(s) método(s) onde a mesma foi encontrada.
Sintaxe
Reflection.getMethodsObjectByAnnotation( xParam,cAnnotationName )
Parâmetros
Nome | Tipo | Descrição | Obrigatório | Referência |
|---|---|---|---|---|
xParam** | objet/caractere | Objeto instância da classe/nome da classe** onde a busca pela Annotation será realizada | X | |
cAnnotationName | caractere | Nome da Annotation a ser procurada | X |
Implementação de comportamento
A partir do build 24.3.0.0, também haverá a opção de passar simplesmente o nome da classe em xParam, conforme exemplo 2. Mas continua valendo a passagem da instância do objeto (exemplo 1).
Retorno
Nome | Tipo | Descrição |
|---|---|---|
aRet | Array | Array contendo em cada posição um objeto Json com a propriedade cMethodName onde o valor é o método onde a Annotation foi encontrada. Caso não haja resultado a array retorna vazia. |
Exemplo
exemplo1.tlpp
#include "tlpp-core.th"
@annotation AnnotationGetMethodsObjectByAnnotation
@end
Class GetMethodsObjectByAnnotation
Public Method New()
@AnnotationGetMethodsObjectByAnnotation()
Public Method MethodWithAnnotation()
EndClass
Method New() class GetMethodsObjectByAnnotation
Return Self
Method MethodWithAnnotation() class GetMethodsObjectByAnnotation
Return
Function u_testGetMethodsObjectByAnnotation()
Local ObjMethod
Local oObj
oObj := GetMethodsObjectByAnnotation():New()
ObjMethod := Reflection.getMethodsObjectByAnnotation(oObj, "AnnotationGetMethodsObjectByAnnotation")
Conout("Nome do Metodo: " + ObjMethod[1]:cMethodName)
Return
exemplo2.tlpp
#include "tlpp-core.th"
@annotation AnnotationGetMethodsObjectByAnnotation
@end
Class GetMethodsObjectByAnnotation
Public Method New()
@AnnotationGetMethodsObjectByAnnotation()
Public Method MethodWithAnnotation()
EndClass
Method New() class GetMethodsObjectByAnnotation
Return Self
Method MethodWithAnnotation() class GetMethodsObjectByAnnotation
Return
Function u_testGetMethodsObjectByAnnotation()
Local ObjMethod
Local oObj
ObjMethod := Reflection.getMethodsObjectByAnnotation("GetMethodsObjectByAnnotation", "AnnotationGetMethodsObjectByAnnotation")
Conout("Nome do Metodo: " + ObjMethod[1]:cMethodName)
Return
Resultado dos Exemplos
Nome do Metodo: MethodWithAnnotation
Abrangência
17.3.0.3
Veja também
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas