打字猴:1.700483241e+09
1700483241 }
1700483242
1700483243 @Override
1700483244
1700483245 public void exec(ProductEvent event){
1700483246
1700483247 //事件的源头
1700483248
1700483249 Product p=event.getSource();
1700483250
1700483251 //事件类型
1700483252
1700483253 ProductEventType type=event.getEventType();
1700483254
1700483255 System.out.println(“平民处理事件:”+p.getName()+“诞生记,事件类型=”+type);
1700483256
1700483257 }
1700483258
1700483259 }
1700483260
1700483261 平民只处理新建立的事件,其他事件不做处理,我们再来看贵族级别的事件处理者,如代码清单36-12所示。
1700483262
1700483263 代码清单36-12 贵族
1700483264
1700483265 public class Nobleman extends EventCustomer{
1700483266
1700483267 //定义贵族能够处理的事件的级别
1700483268
1700483269 public Nobleman(){
1700483270
1700483271 super(EventCustomType.EDIT);
1700483272
1700483273 super.addCustomType(EventCustomType.CLONE);
1700483274
1700483275 }
1700483276
1700483277 @Override
1700483278
1700483279 public void exec(ProductEvent event){
1700483280
1700483281 //事件的源头
1700483282
1700483283 Product p=event.getSource();
1700483284
1700483285 //事件类型
1700483286
1700483287 ProductEventType type=event.getEventType();
1700483288
1700483289 if(type.getValue()==EventCustomType.CLONE.getValue()){
1700483290
[ 上一页 ]  [ :1.700483241e+09 ]  [ 下一页 ]