1700482844
//传入事件的源头,默认为新建类型
1700482845
1700482846
public ProductEvent(Product p){
1700482847
1700482848
this(p,ProductEventType.NEW_PRODUCT);
1700482849
1700482850
}
1700482851
1700482852
//事件源头以及事件类型
1700482853
1700482854
public ProductEvent(Product p,ProductEventType_type){
1700482855
1700482856
this.source=p;
1700482857
1700482858
this.type=_type;
1700482859
1700482860
//事件触发
1700482861
1700482862
notifyEventDispatch();
1700482863
1700482864
}
1700482865
1700482866
//获得事件的始作俑者
1700482867
1700482868
public Product getSource(){
1700482869
1700482870
return source;
1700482871
1700482872
}
1700482873
1700482874
//获得事件的类型
1700482875
1700482876
public ProductEventType getEventType(){
1700482877
1700482878
return this.type;
1700482879
1700482880
}
1700482881
1700482882
//通知事件处理中心
1700482883
1700482884
private void notifyEventDispatch(){
1700482885
1700482886
super.addObserver(EventDispatch.getEventDispathc());
1700482887
1700482888
super.setChanged();
1700482889
1700482890
super.notifyObservers(source);
1700482891
1700482892
}
1700482893
[
上一页 ]
[ :1.700482844e+09 ]
[
下一页 ]