1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public class ControleCompose implements Control{
private Control[] controls;
public ControleCompose(Control... controls){
this.controls = controls;
}
public boolean isValid(File fichier){
for(Control control : controls){
if(!control.isValid(fichier)){ return false;}
}
return true;
}
}
// Utilisation
Control controleCompose12 = new ControleCompose(new ControlType1(), new ControlType2());
Control controleCompose23 = new ControleCompose(new ControlType2(), new ControlType3());
Control controleCompose13 = new ControleCompose(new ControlType1(), new ControlType3());
Control controleCompose123 = new ControleCompose(new ControlType1(), new ControlType2(), ControlType3()); |
Partager