Histórico da Página
...
| Pagetitle | ||||
|---|---|---|---|---|
|
Procura e retorna quais anotações estão Efetua a busca de Annotations associadas a um determinado método.
...
| Bloco de código | ||
|---|---|---|
| ||
Reflection.getMethodAnnotationList( oObjxParam, cMethodName) |
Parâmetros
Nome | Tipo | Descrição | Obrigatório | Referência |
|---|---|---|---|---|
oObjxParam** | objeto/caractere** | Objeto instância da classe/nome da classe** onde está definido o método cujas anotações Annotations serão retornadas | X | |
cMethodName | caractere | Nome do método Método onde serão procuradas as anotaçõesX Annotations | X |
| Informações | ||
|---|---|---|
| ||
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 | jRet | Array de JsonObject | array | Array contendo em cada posição um objeto do tipo Json onde cada propriedade é o nome da Annotation encontrada. Caso nada seja encontrado, seu valor é NILCaso não encontre annotation alguma, retorna NIL. Senão, retorna um array onde cada posição é um Json Object representando uma Annotation encontrada. |
Exemplos
| Bloco de código | ||||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
#include "tlpp-core.th" @annotation AnnotationUm testeAnnotationGetMethodAnnotationList01 teste1 as char @end @annotation AnnotationDoisAnnotationGetMethodAnnotationList02 teste2 teste as char @end Class GetMethodAnnotationList class MeuObjeto public data data1 public method new() @AnnotationUm(teste = "Company") @AnnotationDois(teste = "TOTVS") public method exemplo Public Method New() @AnnotationGetMethodAnnotationList01(teste1 = "Primeira Annotation") @AnnotationGetMethodAnnotationList02(teste2 = "Segunda Annotation") Public Method MethodWithAnnotation() EndClass Method New() class GetMethodAnnotationList Return Self Method MethodWithAnnotation() class GetMethodAnnotationList Return Function u_testGetMethodAnnotationList(aResult) Local oObj := GetMethodAnnotationList():New() Local aRet aRet := Reflection.getMethodAnnotationList(oObj, "MethodWithAnnotation") Conout(Len(aRet)) Conout(aRet[1]["teste1"]) Conout(aRet[2]["teste2"]) Return |
| Bloco de código | ||||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
#include "tlpp-core.th" @annotation AnnotationGetMethodAnnotationList01 teste1 as char @end @annotation AnnotationGetMethodAnnotationList02 teste2 as char @end Class GetMethodAnnotationList Public Method New() @AnnotationGetMethodAnnotationList01(teste1 = "Primeira Annotation") @AnnotationGetMethodAnnotationList02(teste2 = "Segunda Annotation") Public Method MethodWithAnnotation() EndClass mainMethod function usoDeAnnotationNew() local oObj := MeuObjeto():New() local jRet jRet class GetMethodAnnotationList Return Self Method MethodWithAnnotation() class GetMethodAnnotationList Return Function u_testGetMethodAnnotationList(aResult) Local aRet aRet := Reflection.getMethodAnnotationList(oObj"GetMethodAnnotationList", "exemploMethodWithAnnotation") conoutConout(Len(jRetaRet)) conoutConout(jRetaRet[1]["testeteste1"]) conoutConout(jRetaRet[2]["testeteste2"]) returnReturn |
Resultado
...
dos Exemplos
2Company
Primeira Annotation
TOTVSSegunda Annotation
Abrangência
17.3.0.3
Veja também
...