• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Use annotation on attribute of a POJO and use that annotation as identifier for logical check  RSS feed

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anybody thow some light on this, or show some example on how to accomplish this:

I would like to annotate attributes of a POJO. That annotation will be used as an indicator later on for some logical operation. The logical operation check is case-sensitivity check of the value of the attribute of POJO

For example, a POJO would look like:




I would like to annotate each attribute of MyObj. Based on the annotation, I can do a logical check on case sensitivity of the value of the field of MyObj instance.





In other words, I want to annotate every field in a POJO for case sensitivity. If the annotation is present in a field, then I will handle that field differently.

My questions:
1. Could anyone show me an example on how to annotate every field of POJO for similar situation?
2. Could somebody show me an example of how to later interrogate a field of POJO to identify if that field were annotated with caseSensitivity annotation?
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Annotating the field is as simple as using @MyAnnotation(...)--I'm not sure what the problem is.

I'd suggest checking out any of the annotation tutorials available on the net, including Sun's Java site. Heck, a trivial Google search returns the following hit: using annotations to specifiy property constraints, which is precisely what you're doing.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!