Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Instrospection and properties

 
Rick DeBay
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class:

public class Foo
{
long ndc;
long largerNdc;
public long getLargerNdc()
{
return largerNdc;
}
public void setLargerNdc(byte b)
{
if ( b > 99 || b < 0 )
{
throw new IllegalArgumentException("Larger NDC suffix must be from 0 through 99");
}
largerNdc = (getNdc_9() * 100) + b;
}
public long getNdc_9()
{
return ndc / 100;
}
}

When I get the property descriptors, I get null for the write method:
propClass=long
writeMethod=null

Granted the 'byte' type of the setter is probably confusing Instrospector.getBeanInfo(), but I can't find anything in the API saying this could be a problem.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The return type of the getter and the argument type of the setter have to match; otherwise the getter is interpreted as a read-only property of its return type.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic