You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Michael Dürig <md...@apache.org> on 2012/09/14 10:36:51 UTC
NodeTypeDefinition.getDeclaredPropertyDefinitions() contract weirdness!?
Hi,
The contract for NodeTypeDefinition.getDeclaredPropertyDefinitions()
says: "In implementations that support node type registration, if this
NodeTypeDefinition object is actually a newly-created empty
NodeTypeTemplate, then this method will return null."
Why null and not an empty array? Is there a case supporting this
behaviour or is this just the implementation leaking into the spec.?
There is even a test case
(NodeTypeCreationTest.testEmptyNodeDefinitionTemplate) which
specifically tests this part of the contract.
Specifically requiring null asks for additional null checks and
complicates the implementation and usage. Here is what I had to do to
make NodeTypeCreationTest.testEmptyNodeDefinitionTemplate pass:
http://svn.apache.org/viewvc?view=revision&revision=1384683
While not terribly complex still weird.
Michael
Re: NodeTypeDefinition.getDeclaredPropertyDefinitions() contract
weirdness!?
Posted by Michael Dürig <md...@apache.org>.
On 14.9.12 11:46, Jukka Zitting wrote:
> Hi,
>
> On Fri, Sep 14, 2012 at 10:36 AM, Michael Dürig <md...@apache.org> wrote:
>> Why null and not an empty array? Is there a case supporting this behaviour
>> or is this just the implementation leaking into the spec.?
>
> IIRC the idea was to distinguish between the cases where there are no
> definitions (empty array) and where no definition information is yet
> available (null, the template is still being constructed).
Hmm ok that's what I though. So these are expected to return null until
getPropertyDefinitionTemplates() has been called for the first time. In
other words: you need to call getPropertyDefinitionTemplates() to add an
empty list of property definitions. Still weird ;-)
Michael
>
> BR,
>
> Jukka Zitting
>
Re: NodeTypeDefinition.getDeclaredPropertyDefinitions() contract weirdness!?
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Fri, Sep 14, 2012 at 10:36 AM, Michael Dürig <md...@apache.org> wrote:
> Why null and not an empty array? Is there a case supporting this behaviour
> or is this just the implementation leaking into the spec.?
IIRC the idea was to distinguish between the cases where there are no
definitions (empty array) and where no definition information is yet
available (null, the template is still being constructed).
BR,
Jukka Zitting