JavaBeans PropertyChangeSupport Template

by Jay Jonas

Property-change events occur whenever the value of a bound property changes for a java bean. You can use a Eclipse template to help you to write all the standard setter code

Open Windows | Preferences. Browse to Java | Editor | Templates. Click on New and enter property_change_support as Name, choose Java Statements as Context and mark Automatically Insert option. Write a meaning description as “property change support for setter method” and copy & paste into Pattern the code as follows:

if (this.${enclosing_method_arguments} == null && ${enclosing_method_arguments} == null) {
propertyChangeSupport.firePropertyChange("${enclosing_method_arguments}", this.${enclosing_method_arguments}, ${word_selection})

Take care about that there is no new line at the end of the last line.
Take notes and will never forget it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: