Extending builders

Daniel Fuchs daniel.fuchs at oracle.com
Thu Nov 22 07:01:47 PST 2012

On 11/22/12 3:40 PM, Eva Krejcirova wrote:
> Hi,
> There is one more thing which needs to be sorted out before adding new
> methods to builders:
> SceneBuilder and FXML use builders to find names of properties of a
> class, so they need to have a way to differentiate between the new
> convenience methods and the methods which correspond to properties of a
> class. Daniel, is this still true?
> Last time we discussed this, Daniel suggested to annotate these new
> convenience methods. If we go this way, we need to create a new runtime
> annotation (and find a name for it :-) )
> Eva

Hi Eva,

Yes this is still true. Note that SceneBuilder actually uses
builders only in special cases - for WebView - for instance -
because of the fake location attribute available on WebViewBuilder
only - and for any type which has no public constructors (e.g.: all 
charts, Insets, etc...)

However - SceneBuilder discovers whether there are constructor 
properties by introspecting ClassX and ClassXBuilder and comparing
the results: it takes the name of all the single parameter
instance methods in ClassXBuilder which returns a builder,
remove the names of all writable (getter+setter) properties
found in ClassX, and what remain are assumed to be constructor properties.

As long as the convenience methods have more than 1 parameter
(varargs count for 1)  then this logic should remain valid.

The FXMLLoader's JavaFXBuilderFactory also introspects builders
in order to find out writable properties and type of properties,
so that's another place you will have to look at
(class JavaFXBuilderFactory.JavaFXBuilder).

best regards,

-- daniel

More information about the openjfx-dev mailing list