打字猴:1.700482806e+09
1700482806 //修改一个产品
1700482807
1700482808 EDIT_PRODUCT(3),
1700482809
1700482810 //克隆一个产品
1700482811
1700482812 CLONE_PRODUCT(4);
1700482813
1700482814 private int value=0;
1700482815
1700482816 private ProductEventType(int_value){
1700482817
1700482818 this.value=_value;
1700482819
1700482820 }
1700482821
1700482822 public int getValue(){
1700482823
1700482824 return this.value;
1700482825
1700482826 }
1700482827
1700482828 }
1700482829
1700482830 这里定义了4个事件类型,分别是新建、修改、删除以及克隆,比较简单。我们再来看产品的事件,如代码清单36-4所示。
1700482831
1700482832 代码清单36-4 产品事件
1700482833
1700482834 public class ProductEvent extends Observable{
1700482835
1700482836 //事件起源
1700482837
1700482838 private Product source;
1700482839
1700482840 //事件的类型
1700482841
1700482842 private ProductEventType type;
1700482843
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
[ 上一页 ]  [ :1.700482806e+09 ]  [ 下一页 ]