• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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?
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.
Are you here to take over the surface world? Because this tiny ad will stop you!
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic