[API Review] Property and expression conversion methods

Martin Sladecek martin.sladecek at oracle.com
Mon Feb 18 04:38:08 PST 2013


Hello,

there are 2 JIRA issues requesting some conversion between primitive 
expression/properties/observablevalues and theirs object counterparts, 
as primitive types actually use Number as generics parameter. To avoid 
backwards incompatibility by changing the generics parameters to more 
specific types, we decided to introduce conversion methods to these 
types, so that you can use them as objects of the same (generics) type.

Here are the JIRA issues:
http://javafx-jira.kenai.com/browse/RT-25996
http://javafx-jira.kenai.com/browse/RT-19020

And here are the proposed methods. Using Double here, but the same API 
will be also for Float, Integer, Long and Boolean.

DoubleExpression:

public ObjectExpression<Double> asObject();

ReadOnlyDoubleProperty:

@Override
public ReadOnlyObjectProperty<Double> asObject();

DoubleProperty:

@Override
ObjectProperty<Double> asObject();


The conversion from object to primitive will be provided through static 
methods (for Double, Float, Integer and Long):

DoubleExpression:

public static <T extends Number> DoubleExpression 
doubleExpression(ObservableValue<T>)

ReadOnlyDoubleProperty:

public static <T extends Number> ReadOnlyDoubleProperty 
readOnlyDoubleProperty(ReadOnlyProperty<T>);

DoubleProperty:

public static <T extends Number> DoubleProperty doubleProperty(Property<T>);


... and for Boolean:


BooleanExpression:

public static BooleanExpression booleanExpression(ObservableValue<Boolean>)

ReadOnlyBooleanProperty:

public static ReadOnlyBooleanProperty 
readOnlyBooleanPropety(ReadOnlyProperty<Boolean>);

BooleanProperty:

public static BooleanProperty booleanProperty(Property<Boolean>);

Regards,
-Martin



More information about the openjfx-dev mailing list