Major improvements to @Preference in e(fx)clipse 2.2.0


With 2.1.0 we introduced our custom @Preference annotation who is to be preferred over the one available as part of the Eclipse 4 Application Platform.

With the next nightly build there are even more reasons to use our annotation because you get even cooler features:

Support for default values

If there’s no value found in the preference store you most likely don’t want to retrieve a default value null (String), false (boolean), 0 (int & long & float & double) but a custom one. You can now define the default value in the annotation

class Component {
@Inject
@Preference(key="velocity",defaultValue="1000")
private int velocity;
}

Support for more value types

It is fairly likely that you want not only store/retrieve standard values like int, long, float, double and String but eg date or time.

class Component {
@Inject
@Preference(key="lastModified")
private java.time.Instant lastModified;
}

The support for “value types” is provided by a new service named ValueSerializer who supports the most common value types (eg values in java.time) and if you have your own types you contribute your own serializers.

Complex objects

While the above introduced support for “value types” works for things like date and time it is not unlikely that you have to remember non trivial objects like configurations the new support for complex values might get you excited

@XmlRootElement
public class Complex {
private String name;
private int value;
private List<Complex> children;

// ....
}

class Component {
@Inject
@Preference(key="complexData")
private Complex complexData;
}

Serialization and Deserialization is provided through the ObjectSerializer service

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Major improvements to @Preference in e(fx)clipse 2.2.0

  1. Pingback: JavaFX links of the week, September 28 // JavaFX News, Demos and Insight // FX Experience

  2. mok707 says:

    Hi Tom, where can I download the standalone version of e(fx)clipse 2.2.0 ? The http://downloads.efxclipse.bestsolution.at/downloads/nightly/sdk/ only has 2.1.0 version. Appreciate much! Manny

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.