Currently creating a read only variant of a writable property must be done in this way:
ReadOnlyObjectWrapper<X> writableX
= new ReadOnlyObjectWrapper<>();
ReadOnlyProperty<X> readOnlyX = writableX.getReadOnlyProperty();
The name of the wrapper (ReadOnlyObjectWrapper) is confusing; it's actually a writable property. Using plain `ObjectProperty<X>` for this declaration to alleviate this makes the `getReadOnlyProperty` method inaccessible.
The word Wrapper is also a source of confusion. Nothing is wrapped, it is a subclass that re-introduces ReadOnly in the hierarchy (all ObjectProperties are already ReadOnlyObjectProperties). In other words, this "wrapper" can't be used to wrap an existing property.
I propose to simplify this and add this functionality to all properties by default. Instead of having to use this class, any property could offer a read only variant of itself by calling `getReadOnlyProperty`. The above example would then become:
ObjectProperty<X> writableX
= new SimpleObjectProperty<>();
ReadOnlyProperty<X> readOnlyX = writableX.getReadOnlyProperty();
Note that it is also possible to cast `writableX` to `ReadOnlyProperty<X>` and although that communicates the correct intent, the encapsulation could be broken by casting it back to `ObjectProperty<X>`.
The implementation would not be any heavier than the current solution. A new instance is still created when a read only property is desired, just like `ReadOnlyObjectWrapper` creates the internal private class `ReadOnlyPropertyImpl`.
ReadOnlyObjectWrapper<X> writableX
= new ReadOnlyObjectWrapper<>();
ReadOnlyProperty<X> readOnlyX = writableX.getReadOnlyProperty();
The name of the wrapper (ReadOnlyObjectWrapper) is confusing; it's actually a writable property. Using plain `ObjectProperty<X>` for this declaration to alleviate this makes the `getReadOnlyProperty` method inaccessible.
The word Wrapper is also a source of confusion. Nothing is wrapped, it is a subclass that re-introduces ReadOnly in the hierarchy (all ObjectProperties are already ReadOnlyObjectProperties). In other words, this "wrapper" can't be used to wrap an existing property.
I propose to simplify this and add this functionality to all properties by default. Instead of having to use this class, any property could offer a read only variant of itself by calling `getReadOnlyProperty`. The above example would then become:
ObjectProperty<X> writableX
= new SimpleObjectProperty<>();
ReadOnlyProperty<X> readOnlyX = writableX.getReadOnlyProperty();
Note that it is also possible to cast `writableX` to `ReadOnlyProperty<X>` and although that communicates the correct intent, the encapsulation could be broken by casting it back to `ObjectProperty<X>`.
The implementation would not be any heavier than the current solution. A new instance is still created when a read only property is desired, just like `ReadOnlyObjectWrapper` creates the internal private class `ReadOnlyPropertyImpl`.