Valid JavaBeans names for boolean getter methods

According to the JavaBeans specification section 8.3.2: Boolean properties In addition, for boolean properties, we allow a getter method to match the pattern: public boolean is<PropertyName>(); This “isPropertyName” method may be provided instead of a “get<PropertyName>” method, or it may be provided in addition to a “get<PropertyName>” method. In either case, if the is<PropertyName> method … Read more

Java Interface Usage Guidelines — Are getters and setters in an interface bad?

I don’t see why an interface can’t define getters and setters. For instance, List.size() is effectively a getter. The interface must define the behaviour rather than the implementation though – it can’t say how you’ll handle the state, but it can insist that you can get it and set it. Collection interfaces are all about … Read more

Easy way of populating Javabeans based on request parameters

For that Apache Commons BeanUtils is often used. BeanUtils.populate(bean, request.getParameterMap()); That’s it. To get a step further, you can adopt a MVC framework which uses Javabeans as models so that you don’t need to worry about them at all, such as JSF or Spring MVC. Unrelated to the concrete question, using getParameterValues() is clumsy in … Read more