Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Nome

Tipo

Descrição

Obrigatório

Referência

xParam

objeto/caractere** 

Objeto instância da classe/nome da classe** onde será procurado a Annotation.

X


cMethodName
caractereNome do método onde será procurada a Annotation.           X
cAnnotationName 

caractere

Nome da Annotation que será procurada.

X


Informações
titleImplementaçã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

jRet

objeto

Objeto Json com a propriedade da Annotation contendo o seu valor. Caso não encontre retorna  NIL .

...

Bloco de código
languagecpp
themeEclipse
titletest_doc_getMethodAnnotationexemplo1.tlpp
linenumberstrue
#include "tlpp-core.th"

@annotation AnnotationGetMethodAnnotation
nickname as char
@end

Class GetMethodAnnotation

	Public Method New()

	@AnnotationGetMethodAnnotation(nickname = "Totvs")
	Public Method MethodWithAnnotation()
EndClass

Method New() class GetMethodAnnotation
Return Self

Method MethodWithAnnotation() class GetMethodAnnotation
Return

Function u_testGetMethodAnnotation()
	Local oObj := GetMethodAnnotation():New()
	Local jRet
	If (
    jRet := Reflection.isAnnotationMethodPresentgetMethodAnnotation(oObj, "MethodWithAnnotation", "AnnotationGetMethodAnnotation")  
	If (valType(jRet) <> 'U')
		Conout(jRet["nickname"])
	EndIf

Return
Bloco de código
languagecpp
themeEclipse
titleexemplo2.tlpp
linenumberstrue
#include "tlpp-core.th"

@annotation AnnotationGetMethodAnnotation
nickname as char
@end

Class GetMethodAnnotation

	Public Method New()

	@AnnotationGetMethodAnnotation(nickname = "Totvs")
	Public Method MethodWithAnnotation()
EndClass

Method New() class GetMethodAnnotation
Return Self

Method MethodWithAnnotation() class GetMethodAnnotation
Return

Function u_testGetMethodAnnotation()
	Local jRet
	
    jRet := Reflection.getMethodAnnotation(oObj"GetMethodAnnotation", "MethodWithAnnotation", "AnnotationGetMethodAnnotation")  
	If (valType(jRet) <> 'U')
		Conout(jRet["nickname"])
	EndIf

Return

Resultado do Exemplo

...