I am trying to study this piece of code where private nested class implements a nested interface.
public class ConfigurationManager {
private class ChainPowerListener implements PowerListener {
private List<PowerListener> powerListeners = new CopyOnWriteArrayList<>();
ChainPowerListener() {
super();
}
public void registerListener(PowerListener listener) {
powerListeners.add(listener);
}
@Override
public void onAppPowerOn() {
}
@Override
public void onAppPowerOff() {
}
}
}
public interface AppPower {
boolean isPowerOn();
void setPowerListener(PowerListener listener);
public interface PowerListener {
void onAppPowerOn();
void onAppPowerOff();
}
}
- What does super refer to in the ChainPowerListener() constructor above? Is it the class that implements AppPower interface?
- What is the benefit of this pattern if at all? Is this pattern common in Java world?
I am from c# background who is just starting to learn java. So hope you will be lenient if I am asking something stupid :)
Aucun commentaire:
Enregistrer un commentaire