Árvore de páginas

Versões comparadas

Chave

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

...

Bloco de código
collapsefalse
Reflection.getMethodsByAnnotation( oObjxParam,cAnnotationName )

Parâmetros

Nome

Tipo

Descrição

Obrigatório

Referência

oObjxParam**

objeto/caractere**

Objeto instância da classe/nome da classe** na qual a busca será realizada

X


cAnnotationName 
caractereNome da Annotation a 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

aRet

Array

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

...

Bloco de código
languagecpp
themeEclipse
titletest_doc_getGetMethodsByAnnotationexemplo1.tlpp
linenumberstrue
#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

Bloco de código
languagecpp
themeEclipse
titleexemplo2.tlpp
linenumberstrue
#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
	
	aRet := Reflection.getMethodsByAnnotation("GetMethodsByAnnotation", "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

...

dos Exemplos

ANOTHERMETHODWITHANNOTATION
METHODWITHANNOTATION

...