Bookmark Topic Watch Topic
  • New Topic

How to use enums to create generic API for Search and Filter of POJOs in Java?  RSS feed

 
James Dekker
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Report post to moderator
Lets say you have a particular enum called Field:


And another enum called:


And you have a corresponding Java interface called Music


Which the implementation looks liks this:


How would you use this API to implement the following two methods?



Any suggestions will help...
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Report post to moderator
There is something not quite right about that. You have a getYear method which you appear to have forgotten from the interface. You also have a getDescription method which appears to return “DESCRIPTION” regardless.
The getField method looks even weirder. Please explain what you hoped it would do.
 
James Dekker
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is how the coding puzzle came... I am supposed to provide implementation in the Field's enums?
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Report post to moderator
What puzzle? Please continue all discussion in your other thread. Please provide full details there of what the problem is.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!