Re: Java 8 optionals
Re: Java 8 optionals
- Subject: Re: Java 8 optionals
- From: Henrique Prange <email@hidden>
- Date: Mon, 25 May 2015 11:18:13 -0300
>
> On 25/05/2015, at 05:37, Johann Werner <email@hidden> wrote:
>
> Hi Mark,
>
> NSKeyValueCoding.DefaultImplementation is a static class which renders it quite difficult to modify or replace some functionality. One way to do so would be to reimplement the class with your modifications and put that prior to the original class on your build path so that it is loaded before the original one. This procedure is used at some places in Wonder code already.
>
> Another, less drastic, way would be to create a subclass of Optional. That ERXOptional could then implement NSKeyValueCoding to fire up a key path on its internal value (or null) instead of itself. That would fix valueForKey(Path) on chains where ERXOptional objects are included. Of course this doesn’t work where you have no control on what optional class is used/returned.
Unfortunately, Optional is final and cannot be extended. :(
Cheers,
Henrique
>
> jw
>
>
>> Am 23.05.2015 um 23:24 schrieb Mark Wardle <email@hidden>:
>>
>> Dear all,
>>
>> I’ve migrated to java 8 in development and deployment and am now dabbling with new “features”.
>>
>> Optionals seem a potentially good way of documenting nullability although the syntax is currently rather cumbersome it seems likely that in future versions, the syntax will improve.
>>
>> However, key value coding fails when an object is encapsulated by an Optional. Intuitively, these should be unwrapped during KVC so that “normal” behaviour continues - i.e. as KVC gracefully handles null pointers in arbitrary key paths it should gracefully handle optionals containing either a value or null.
>>
>> How would the handling of KVC be patched for future java versions? Is this something fixable now? Does all KVC work via NSKeyValueCoding.DefaultImplementation or are there multiple implementations? I used to have a java decompiler working but haven’t set this up since upgrading eclipse so it has been difficult to fathom the internals.
>>
>> Mark
>>
>> --
>> Dr. Mark Wardle
>> Consultant Neurologist, University Hospital Wales, Cardiff, UK
>> Deputy Sub-Dean for Assessments and Honorary Lecturer, Cardiff University
>> Email: email@hidden or email@hidden Twitter: @mwardle
>> Telephone: 02920745274 (secretary) or facsimile: 02920744166
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden