Hi Devs,

The implementation of the immutable version of reference is almost ready
now. It introduce the parameters on reference as suggested, but we now have
a discussion on how the constructors of "typed" entity reference should be.

My initial dev was to provide constructor like:

But Vincent have different vision of this, here its comment extracted from
GitHub (
https://github.com/xwiki/xwiki-platform/commit/cea424914f40ce924afbc49b3159bc8934251aac#commitcomment-721603)
:

My proposal was:
> - generic params in EntityReference
> - helpers methods for get/setLocale and get/setVersion in DocumentReference
>
> Now the fact that we're making the refs immutable changed this since it's
> no longer possible.
>
> I don't think multiplying the constructor signatures is a good idea.
>
> We could either have:
>
> public DocumentReference(String wikiName, List spaceNames, String
> pageName, Map<String, Object> parameters)
>
> or
>
> public DocumentReference(String wikiName, List spaceNames, String
> pageName, Pair<String, Object>... parameters)
>
> where Pair is
> http://commons.apache.org/lang/api-3.0-beta/org/apache/commons/lang3/Pair.html
>
> Maybe this needs some discussion on the devs list rather than here to make
> sure everyone sees it?
>

I am myself not really happy with that since I dislike the idea that
parameter are generic on "typed" references.
Do not like either the idea to provide keys for creating a Map or Pairs,
since the implementation details that use Map should not be so exposed IMO.

There should not be so much parameter on a single "typed" reference, and
these should be easy to provide. Creating Maps in java is not fun in syntax
for that IMO, and is far too open.

I had propose using overloaded constructor like

public DocumentReference(String wikiName, List<String> spaceNames, String
pageName, Locale locale)

or if something more flexible should be used

public DocumentReference(String wikiName, List<String> spaceNames, String
pageName, Object... parameters)

where parameters is later interpreted based on object type and limited to
those used for a given typed reference.

Here Vincent comments on this:

> The automatic mapping idea seems a bad idea to me (too magic and doesn't
> work in a lot of cases).


Maybe some of you have an even better idea ?

Denis
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to