1 19 20 package org.apache.cayenne.map.event; 21 22 import org.apache.cayenne.event.CayenneEvent; 23 import org.apache.cayenne.util.Util; 24 25 30 public abstract class MapEvent extends CayenneEvent { 31 32 36 public static final int CHANGE = 1; 37 38 41 public static final int ADD = 2; 42 43 46 public static final int REMOVE = 3; 47 48 protected int id = CHANGE; 49 protected String oldName; 50 protected boolean oldNameSet; 51 52 57 public MapEvent(Object source) { 58 super(source); 59 } 60 61 66 public MapEvent(Object source, String oldName) { 67 super(source); 68 setOldName(oldName); 69 } 70 71 public boolean isNameChange() { 72 return oldNameSet && !Util.nullSafeEquals(getOldName(), getNewName()); 73 } 74 75 80 public int getId() { 81 return id; 82 } 83 84 87 public abstract String getNewName(); 88 89 92 public String getOldName() { 93 return oldName; 94 } 95 96 99 public void setId(int id) { 100 this.id = id; 101 } 102 103 106 public void setOldName(String oldName) { 107 this.oldName = oldName; 108 this.oldNameSet = true; 109 } 110 } 111 | Popular Tags |