[
https://issues.apache.org/jira/browse/PLUTO-589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12846975#action_12846975
]
Eric Dalquist commented on PLUTO-589:
-------------------------------------
It seems that if the goal is for implementations to use custom types the Filter
interface itself should be parameterized.
So instead of:
public interface Filter {
String getFilterName();
Description getDescription(Locale locale);
List<? extends Description> getDescriptions();
Description addDescription(String lang);
DisplayName getDisplayName(Locale locale);
List<? extends DisplayName> getDisplayNames();
DisplayName addDisplayName(String lang);
String getFilterClass();
void setFilterClass(String filterClass);
InitParam getInitParam(String paramName);
List<? extends InitParam> getInitParams();
InitParam addInitParam(String paramName);
List<String> getLifecycles();
void addLifecycle(String lifecycle);
}
Do:
public interface Filter<D extends Description, N extends DisplayName, I extends
InitParam> {
String getFilterName();
Description getDescription(Locale locale);
List<D> getDescriptions();
Description addDescription(String lang);
DisplayName getDisplayName(Locale locale);
List<N> getDisplayNames();
DisplayName addDisplayName(String lang);
String getFilterClass();
void setFilterClass(String filterClass);
InitParam getInitParam(String paramName);
List<I> getInitParams();
InitParam addInitParam(String paramName);
List<String> getLifecycles();
void addLifecycle(String lifecycle);
}
Then you actually have a fully parameterized Filter object that can communicate
the types used by the methods at the class level. From what I know of generics
? should only be used for fields if the actual type cannot be known. To allow
the use case you're suggesting a fully parameterized class should be used.
> alter return types in org.apache.pluto.container.om.portlet.Filter?
> -------------------------------------------------------------------
>
> Key: PLUTO-589
> URL: https://issues.apache.org/jira/browse/PLUTO-589
> Project: Pluto
> Issue Type: Improvement
> Components: portlet container
> Affects Versions: 2.0.0
> Reporter: Nicholas Blair
>
> The return type for the getInitParams() method in
> org.apache.pluto.container.om.portlet.Filter is List<? extends InitParam>.
> This presents an awkward scenario, one particularly present when creating
> unit tests for a FilterChain implementation and attempting to create mock
> Filter implementations.
> The requirement that getInitParams return a class that implements an
> interface _that extends_ InitParam. You cannot simply return a class that
> implements InitParam; you would need to define your own custom interface that
> extends InitParam, and implement your custom interface.
> If the InitParam interface satisfactorily defines what's needed, the
> getInitParams return should be a class that simply implements InitParam.
> Is it possible to modify the return value for getInitParams to simply?
> List<InitParam>
> This also applies to the getDescriptions and getDisplayNames method in the
> same class; both have return values of List<? extends someinterface>, it
> should simply be List<interface>.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.