• Post Reply Bookmark Topic Watch Topic
  • New Topic

PropertyUtils.getPropertyType does not work for Map  RSS feed

 
Viidhya Kishore
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am not sure if I have posted this topic in the right forum.
Please excuse if not so.
I am having a method which uses the PropertyUtils.getPropertyType(item, property) method to determine the type.
Now this method is not working for Map object.
I am to modify this method to work for Map.
i.e I am to write a private method which will perform the functionality of this method for Map object too.
I am not sure where to begin.
Can someone please give me a sample code?

-Vidhya
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you get this class PropertyUtils from?
 
Viidhya Kishore
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.apache.commons.beanutils.PropertyUtils
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are talking about Apache Commons PropertyUtils.

You could start by finding the source code for that class and look how they do it. You will need to use Reflection to get the type of the item.
 
Viidhya Kishore
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did go through the code but I am finding it difficult to understand.
Can you please provide steps for going about?

-Vidhya
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that class is used for JavaBeans, so if you provide the proper JavaBeans BeanDescriptors the code in that class finds the right one and returns information about the contents.

If you have a normal map, not one you made a BeanDescriptor for, you should read the Reflection trail I linked to before and use that to get the type of an item in the map.
 
Viidhya Kishore
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry.
But still confused
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then read the reflection tutorial I linked to earlier.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!