i have icoreclient
interface , aclient
, bclient
classes implements this.
icoreclient
exposed users.
i need add new method in icoreclient
interface. so, needs implemented in both clients. can not make method generic has different signature similar functionalities.
i have 2 interfaces xx
, yy
clienta
implements xx
, clientb
implements yy
so, decided add new testmethod
in icoreclient
provide me instance of xx
or yy
depending upon clients.
i want return instance of these interfaces single method depending upon condition.
in clienta
:
public xx testmethod(){ return instanceof xx; }
in clientb
:
public yy testmethod(){ return instanceof yy; }
what should write in icoreclient
interface?
public zz testmethod()
i tried putting dummy interface zz
(acting common supertype) both xx
, yy
implementing this. still not able expose methods of xx
, yy
in respective clients got typecasted in zz
.
is there known approach kind of scenario?
edit: if make return type object
, method of these interfaces not exposed. although, object contains instance of xx
or yy
,
user still needs cast (xx
or yy
how user know?) using methods in interface.. want expose methods of clientx
without having cast clienta
or clientb
...
after edit looks may looking generics. can make interface this
interface icoreclient<t>{// t set each class implementing interface t testmethod(); }
and each of classes can like
class clienta implements icoreclient<xx>{ xx testmethod(){ //return xx } } class clientb implements icoreclient<yy>{ yy testmethod(){ //return yy } }
Comments
Post a Comment