users@javaserverfaces-spec-public.java.net

[jsr344-experts mirror] [jsr344-experts] ViewDeclarationLanguage API review

From: Andy Schwartz <andy.schwartz_at_oracle.com>
Date: Tue, 12 Mar 2013 14:58:49 -0400

Gang -

Minor comments on ViewDeclarationLanguage:

Index: javax/faces/view/ViewDeclarationLanguage.java
===================================================================
--- javax/faces/view/ViewDeclarationLanguage.java (revision 8845)
+++ javax/faces/view/ViewDeclarationLanguage.java (revision 11719)

+ /**
+ * <p class="changed_added_2_2">Return the list of resource library
+ * contracts that will be made available for use in the view
+ * specified by the argument {_at_code viewId}. If no match is found,
+ * return an empty list. See section JSF.7.7.2 for the
+ * specification of the default implementation. For backward
+ * compatibility with prior implementations, an implementation is
+ * provided that returns {_at_code null}, but any implementation
+ * compliant with the version of the specification in which this
+ * method was introduced must implement it as specified in
+ * JSF.7.7.2. </p>
+ *
+ * @param context the {_at_code FacesContext} for this request
+ * @param viewId the view id for which the applicable resource library
+ * contracts should be calculated.
+ *
+ * @since 2.2
+ */
+
+ public List<String> calculateResourceLibraryContracts(FacesContext
context,
+ String viewId) {
+ return null;
+ }


I don't understand the relationship between:

+ * If no match is found,
+ * return an empty list.

And:

+ * For backward
+ * compatibility with prior implementations, an implementation is
+ * provided that returns {_at_code null}

These statements seem contradictory.

We should spec that:

- The returned List is immutable. And...
- The returned List is guaranteed to be non-null.

The default implementation should return Collections.emptyList() instead
of null.

This avoids forcing callers to explicitly check for a null return value.

Andy