• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Something about .... going for a swim. With this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic