[API Review] Property and expression conversion methods

Martin Sladecek martin.sladecek at oracle.com
Fri Feb 22 01:39:43 PST 2013


I've tried to prototype this and realized, the static method on Property 
will have to be more restricted.
Instead of

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

we will have

public static DoubleProperty doubleProperty(Property<Double>);

The problem here is that when the double property is set, I don't know 
what type should I convert the value to. (may be any Number type).

Expressions and ReadOnlyProperties are OK, as they cannot be set / bound.

If there are no other concerns, can I get "api-approved" for the issues?

Thanks,
-Martin

On 02/21/2013 05:01 PM, steve.x.northover at oracle.com wrote:
> Ok, consistency with asString() seems good to me.
>
> Steve
>
> On 21/02/2013 6:20 AM, Martin Sladecek wrote:
>> As expressions already have asString() that returns StringBinding, I 
>> think it's better to call it asObject(), but I don't strongly insist 
>> on this name, asObjectExpression() is a good option too.
>>
>> -martin
>>
>> On 19.2.2013 23:30, steve.x.northover at oracle.com wrote:
>>> I understand.  Since they are all a kind of expression, perhaps 
>>> asObjectExpression() is the name we should use.
>>>
>>> Another possibility is to create a new instance of the adapter class 
>>> explicitly (ie. new ReadOnlyObjectProperyAdapter(zzzz)) rather than 
>>> zzzzx.asXXX()) method.  Not sure if this is better or worse.
>>>
>>> Steve
>>>
>>> On 19/02/2013 3:26 PM, Martin Sladecek wrote:
>>>> As properties extend read only properties, which extend 
>>>> expressions, using asObject() everywhere would mean we have only 
>>>> one method, which return covariant return type in subclasses.
>>>>
>>>> Renaming these method will result in 3 method in property classes. 
>>>> E.g. DoubleProperty would have:
>>>> ObjectExpression<Double> asObjectExpression();
>>>> ObjectReadOnlyProperty<Double> asReadOnlyObjectProperty();
>>>> ObjectProperty<Double> asObjectProperty();
>>>>
>>>> instead of just having
>>>>
>>>> ObjectProperty<Double> asObject();
>>>>
>>>> which overrides ObjectExpression<Double> asObject() from 
>>>> DoubleExpression.
>>>>
>>>> -Martin
>>>>
>>>> On 02/19/2013 06:44 PM, steve.x.northover at oracle.com wrote:
>>>>> I agree.  asObject seems a bit to general.
>>>>>
>>>>> Steve
>>>>>
>>>>> On 19/02/2013 12:23 PM, Richard Bair wrote:
>>>>>>> public ObjectExpression<Double> asObject();
>>>>>>> public ReadOnlyObjectProperty<Double> asObject();
>>>>>>> ObjectProperty<Double>  asObject();
>>>>>>>
>>>>>>> public static<T extends Number> DoubleExpression 
>>>>>>> doubleExpression(ObservableValue<T>)
>>>>>>> public static<T extends Number> ReadOnlyDoubleProperty 
>>>>>>> readOnlyDoubleProperty(ReadOnlyProperty<T>);
>>>>>>> public static<T extends Number>  DoubleProperty 
>>>>>>> doubleProperty(Property<T>);
>>>>>> I wonder if we ought not use a consistent naming here, such as 
>>>>>> asObjectProperty and asDoubleExpression? Also should it be asFoo 
>>>>>> or toFoo? Is there a precedent?
>>>>>>
>>>>>> Richard
>>>>
>>



More information about the openjfx-dev mailing list