Árvore de páginas

Versões comparadas

Chave

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

...

Retorna um array com o objeto Attribute de cada um dos atributos uma das propriedades que possuem a annotation no Annotation do objeto enviado.

Sintaxe

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

Parâmetros

Nome

Tipo

Descrição

Obrigatório

Referência

oObjxParam**

objeto/caractere**

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

X


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

Retorna um array com o contendo os objetos do tipo Attribute.

Exemplos

Bloco de código
languagecpp
themeEclipse
titleexemplo1.tlpp
linenumberstrue
#include "tlpp-objectcore.th"
 
@annotation attr
@end
 
Class GetAttributesByAnnotation
 
  @attr()
  Public Data cAttr as Character
  Public Method New()
  
EndClass
 
Method New() class GetAttributesByAnnotation
  ::cAttr := "initialized"
Return self
 
Function u_testGetAttributesByAnnotation()
  
  Local aAttr as Array
  local obj   as Object

  obj   := GetAttributesByAnnotation():New()
  aAttr := Reflection.getAttributesByAnnotation(obj, "attr")
  ConOut(aAttr[1]:cAttributeName)
  ConOut(aAttr[1]:cAttributeType)
  
Return
Bloco de código
language

...

cpp
themeEclipse
titleexemplo2.tlpp
linenumberstrue
#include "tlpp-core.th"
 
@annotation attr
@end
 
Class GetAttributesByAnnotation
 
  @attr()
  Public Data cAttr as Character
  Public Method New()
  
EndClass
 
Method New() class GetAttributesByAnnotation
  ::cAttr := "initialized"
Return self
 
Function u_testGetAttributesByAnnotation()
  
  Local aAttr as Array

  aAttr := Reflection.getAttributesByAnnotation("GetAttributesByAnnotation", "attr")
  ConOut(aAttr[1]:cAttributeName)
  ConOut(aAttr[1]:cAttributeType)
  
Return

Resultado dos Exemplos

-----------------------
TESTEATTRCATTR
CHARACTER
-----------------------

...