Árvore de páginas

Você está vendo a versão antiga da página. Ver a versão atual.

Comparar com o atual Ver Histórico da Página

« Anterior Versão 2 Próxima »

Efetua a busca da Annotation dentro de um objeto retornando uma lista contendo o(s) nome(s)  do(s)  método(s) onde a mesma foi encontrada.

Sintaxe

Reflection.getMethodsByAnnotation( oObj,cAnnotationName )

Parâmetros

Nome

Tipo

Descrição

Obrigatório

Referência

oObj

objeto

Objeto na qual a busca será realizada

X


cAnnotationName 
caractereNome da Annotation a ser procurada           X

Retorno

Nome

Tipo

Descrição

aRet

Array

Array contendo os métodos que possuem a Annotation solicitada. Caso não encontre a array retorna vazia.

Exemplo

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


@annotation AnnotationGetMethodsByAnnotation
property1 as char
@end

Class GetMethodsByAnnotation

	Public Method New()

	@AnnotationGetMethodsByAnnotation(property1 = "Method Annotation")
	Public Method MethodWithAnnotation()

	@AnnotationGetMethodsByAnnotation(property1 = "Method Annotation")
	Public Method AnotherMethodWithAnnotation()
EndClass

Method New() class GetMethodsByAnnotation
Return Self

Method MethodWithAnnotation() class GetMethodsByAnnotation
Return

Method AnotherMethodWithAnnotation() class GetMethodsByAnnotation
Return

Function u_testGetMethodsByAnnotation()
	Local aRet := {} as array
	Local oObj

	oObj := GetMethodsByAnnotation():New()
	aRet := Reflection.getMethodsByAnnotation(oObj, "AnnotationGetMethodsByAnnotation")
	if(valType(aRet) == "A" .and. len(aRet) > 0)
		aEval(aRet,{|x| Conout(x)} )
	else
		Conout('Nao foi encontrada Annotation com os parametros solicitados')
	endIf
Return

Resultado do Exemplo

ANOTHERMETHODWITHANNOTATION
METHODWITHANNOTATION

Abrangência

17.3.0.3

Veja também

  • Sem rótulos