Interface design query!!
Hi all,
I want to define a generic interface with set of operations, and the the different implementations of this interface are having different operations signiture. i.e how to define a generic interface for which each of the implementation can have operations with different signitures?
Waiting for the reply,
Thanks in advance.
MK
[365 byte] By [
MithunKa] at [2007-10-3 8:11:24]

hi mithun,
i can explain this to u with a sdimple example
in the interface add a method that takes an object as a parameter...... so no matter what arguement u pass everything belongs to the Object Class
if u want to pass primitives as parameters then wrap them with wrapper classes and that should work fine
Thanks and Regards
Naveen
Hi Naveen,
Thanks for the reply. The problem here is the parameters are going to differ in each of the implementation.
For ex. below is the generic interface which client would talk to
interface generic{
public void login(String userName, String password)
}
Now in two different scenarios, the implementation requires different set of params like
case 1:public void login(String userName)
case2:public void login(String userName, String password, String port)
So in such cases how to define a generic interface operations, where even if we think of taking an object as a parameter, the object structure is going to differ.
well, you overload the login() method
login(String username, String password)
login(String username)
the password-less method would simply delegate to the 2-arg method, with a suitable argument for 'password' eg
void login(String username) {
login(username, NO_PASSWORD_NEEDED);
}