Re: No overloading of types by the number of type parameters
Stefan Ram wrote:
Now, I needed to apply it as follows
Alternatively, you can define a marker (non generic) Domain interface
and various (generic or not) interfaces extending it, for example:
public interface Domain {}
public interface D1<P1> extends Domain {
P1 getP1();
void setP1(P1 value);
}
public interface D2<P1,P2> extends D1<P1> {
P2 getP2();
void setP2(P2 value);
}
public interface D3<P1,P2,P3> extends D2<P1,P2> {
P3 getP3();
void setP3(P3 value);
}
/* and so on...*/
And then have a single action interface defined that way:
public interface ParametrizedAction<D extends Domain> {
void of(D domain);
}
The actions then might be implemented as follows:
public class AgentStreamAction
implements ParametrizedAction<D2<HttpURLConnection,InputStream>>
{
public void of(D2<HttpURLConnection,InputStream> domain) {
of(domain.getP1(), domain.getP2());
}
public void of(HttpURLConnection connection, InputStream stream) {
/*...*/
}
}
That above "domains" model might be nicely supported with reflection,
for e.g. generic abstract Action class implementing "of(Domain)" method,
or some utility classes like Proxy-based universal domains implementation.
piotr