mercredi 10 juin 2020

Difference between java bounded generics vs strategy pattern

I have a util class which is coupled with interface Isupplier.

Class Util<T extends Isupplier>

it has a method execute which has a list of objects which implements Isupplier.

execute(List<T extends Isupplier> objList )

There are classes which implements the methods in Isupplier. And a caller class, which calls execute method for each of the implementation class.

Class A implements Isupplier

Class B implements Isupplier

 Class ACaller{
 //calls Util.execute(List of Object A)`
}
 Class BCaller{
 //calls Util.execute(List of Object B)`
}

Can this be called usage of strategy pattern? Since we are coding to an interface. The strategy can be implementation of Isupplier. Base Strategy as Isupplier. Context as Util?

Aucun commentaire:

Enregistrer un commentaire