Árvore de páginas

Efetua a busca de uma Annotation em uma método de um objeto.

Sintaxe

Reflection.isAnnotationMethodPresent( xParam, cMethodName, cAnnotationName )

Parâmetros

Nome

Tipo

Descrição

Obrigatório

Referência

xParam

objeto/caractere**

Objeto instância da classe/nome da classe** proprietário/a do método onde será procurada a Annotation.

X


cMethodName

caractere

Nome do método onde será procurada a Annotation.

X


cAnnotationName
caractereNome da Annotation que será procurada.           X

Retorno

Nome

Tipo

Descrição

lRet

logico

Retorna .T. caso encontre a Annotation e .F. caso não encontre.

Exemplos

exemplo1.tlpp
#include "tlpp-core.th"

@annotation AnnotationIsAnnotationMethodPresent
nickname as char
@end

Class IsAnnotationMethodPresent

	Public Method New()

	@AnnotationIsAnnotationMethodPresent(nickname = "Company")
	Public Method MethodWithAnnotation()
EndClass

Method New() class IsAnnotationMethodPresent
Return Self

Method MethodWithAnnotation() class IsAnnotationMethodPresent
Return

Function u_testIsAnnotationMethodPresent()
	Local oObj := IsAnnotationMethodPresent():New()
	Conout(Reflection.isAnnotationMethodPresent(oObj, "MethodWithAnnotation", "AnnotationIsAnnotationMethodPresent"))
	Conout(Reflection.isAnnotationMethodPresent(oObj, "MethodWithAnnotation", "NoExist"))
Return
exemplos2.tlpp
#include "tlpp-core.th"

@annotation AnnotationIsAnnotationMethodPresent
nickname as char
@end

Class IsAnnotationMethodPresent

	Public Method New()

	@AnnotationIsAnnotationMethodPresent(nickname = "Company")
	Public Method MethodWithAnnotation()
EndClass

Method New() class IsAnnotationMethodPresent
Return Self

Method MethodWithAnnotation() class IsAnnotationMethodPresent
Return

Function u_testIsAnnotationMethodPresent()
	
	Conout(Reflection.isAnnotationMethodPresent("IsAnnotationMethodPresent", "MethodWithAnnotation", "AnnotationIsAnnotationMethodPresent"))
	Conout(Reflection.isAnnotationMethodPresent("IsAnnotationMethodPresent", "MethodWithAnnotation", "NoExist"))
Return

Resultado dos Exemplos

.T.

.F.

Abrangência

17.3.0.3

Veja também

  • Sem rótulos