JavaBeanPropertyAdapter Reloaded

Michael Heinrichs michael.heinrichs at oracle.com
Fri Jan 6 01:01:41 PST 2012


Hi,

are there any thought about the last point? I am really undecided how to continue. On the one hand I like the idea to use a familiar pattern for the JavaBeanPropertyBuilders, on the other hand I really hate replacing compile time checks with runtime checks. If nobody has an opinion, I will just throw a coin. :-)

Thanks,
Michael


On 04.01.2012, at 10:12, Michael Heinrichs wrote:

>>> public final class ReadOnlyJavaBeanPropertyBuilder {
>>>  public static ReadOnlyJavaBeanBooleanProperty createBooleanProperty(Object bean, String propertyName) throws NoSuchMethodException {...}
>>>  public static <T> ReadOnlyJavaBeanObjectProperty<T> createObjectProperty(Object bean, String propertyName) throws NoSuchMethodException {...}
>>>  // same for all other types
>>> 
>>>  public ReadOnlyJavaBeanPropertyBuilder(String propertyName, Class<?> beanClass) throws NoSuchMethodException {...}
>>>  public ReadOnlyJavaBeanPropertyBuilder(String propertyName, Class<?> beanClass, String getterName) throws NoSuchMethodException {...}
>>>  public ReadOnlyJavaBeanPropertyBuilder(String propertyName, Class<?> beanClass, Method getter) {...}
>>> 
>>>  public ReadOnlyJavaBeanBooleanProperty createBooleanProperty(Object bean) {...}
>>>  public <T> ReadOnlyJavaBeanObjectProperty<T> createObjectProperty(Object bean) {...}
>>>  // same for all other types
>>> }
>>> 
>>> public final class JavaBeanPropertyBuilder {
>>>  public static JavaBeanBooleanProperty createBooleanProperty(Object bean, String propertyName) throws NoSuchMethodException {...}
>>>  public static <T> JavaBeanObjectProperty<T> createObjectProperty(Object bean, String propertyName) throws NoSuchMethodException {...}
>>>  // same for all other types
>>> 
>>>  public JavaBeanPropertyBuilder(String propertyName, Class<?> beanClass) throws NoSuchMethodException {...}
>>>  public JavaBeanPropertyBuilder(String propertyName, Class<?> beanClass, String getterName, String setterName) throws NoSuchMethodException {...}
>>>  public JavaBeanPropertyBuilder(String propertyName, Class<?> beanClass, Method getter, Method setter) {...}
>>> 
>>>  public JavaBeanBooleanProperty createBooleanProperty(Object bean) {...}
>>>  public <T> JavaBeanObjectProperty<T> createObjectProperty(Object bean) {...}
>>>  // same for all other types
>>> }
>> 
>> How do these fit with the existing builders that are generated? Do these use the same semantics / naming pattern / implement the same interface?
>> 
> 
> No, right now they use a different pattern. I am undecided, if we should enforce the same pattern. A Java Bean adapter requires some mandatory parameters for which there are no default values. AFAIK there is no special treatment for such parameters in the builders, which means we cannot check during compile time, if all mandatory parameters were set. With the approach above on the other hand, you are forced to specify the mandatory parameters in the constructor / create()-method.
> 
> JavaBeanBooleanPropertyBuilder.create().propertyName("x").bean(obj).build();
> If we would use the same pattern, we would only be able to check during runtime, if the propertyName was set for example. (Note that we would also need a builder for each type, which is probably not a bad idea anyway.)
> 
> Do you think, we we should drop the compile time check to gain the more familiar pattern?
> 
> 
>> Thanks
>> Richard
>>> 
>>> What do you think?
>>> 
>>> Thanks,
>>> Michael
> 



More information about the openjfx-dev mailing list