import.css=/download/attachments/6062824/tecnologia.css

Efetua a busca de uma Annotation em um objeto.

Sintaxe

Reflection.isAnnotationObjectPresent( xParam, cAnnotationName )

Parâmetros

Nome

Tipo

Descrição

Obrigatório

Referência

xParam

objeto/caracter**

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

X


cAnnotationName 

caractere

Nome da Annotation que será procurada.

X


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

lRet

logico

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

Exemplos

#include "tlpp-core.th"

@annotation AnnotationIsAnnotationObjectPresent
nickname as char
@end

@AnnotationIsAnnotationObjectPresent(nickname = "Company")
Class IsAnnotationObjectPresent
	Public Method New()
EndClass

Method New() class IsAnnotationObjectPresent
Return Self

Function u_testIsAnnotationObjectPresent(aResult)

	Local oObj := IsAnnotationObjectPresent():New()
	
	Conout(Reflection.isAnnotationObjectPresent(oObj, "AnnotationIsAnnotationObjectPresent"))
	Conout(Reflection.isAnnotationObjectPresent(oObj, "NoExist"))
Return
#include "tlpp-core.th"

@annotation AnnotationIsAnnotationObjectPresent
nickname as char
@end

@AnnotationIsAnnotationObjectPresent(nickname = "Company")
Class IsAnnotationObjectPresent
	Public Method New()
EndClass

Method New() class IsAnnotationObjectPresent
Return Self

Function u_testIsAnnotationObjectPresent(aResult)

	Conout(Reflection.isAnnotationObjectPresent("IsAnnotationObjectPresent", "AnnotationIsAnnotationObjectPresent"))
	Conout(Reflection.isAnnotationObjectPresent("IsAnnotationObjectPresent", "NoExist"))
Return

Resultado dos Exemplos

.T.

.F.

Abrangência

17.3.0.3

Veja também