1 56 package org.objectstyle.cayenne.map.event; 57 58 import org.objectstyle.cayenne.event.CayenneEvent; 59 import org.objectstyle.cayenne.util.Util; 60 61 66 public abstract class MapEvent extends CayenneEvent { 67 68 72 public static final int CHANGE = 1; 73 74 77 public static final int ADD = 2; 78 79 82 public static final int REMOVE = 3; 83 84 protected int id = CHANGE; 85 protected String oldName; 86 protected boolean oldNameSet; 87 88 93 public MapEvent(Object source) { 94 super(source); 95 } 96 97 102 public MapEvent(Object source, String oldName) { 103 super(source); 104 setOldName(oldName); 105 } 106 107 public boolean isNameChange() { 108 return oldNameSet && !Util.nullSafeEquals(getOldName(), getNewName()); 109 } 110 111 116 public int getId() { 117 return id; 118 } 119 120 123 public abstract String getNewName(); 124 125 128 public String getOldName() { 129 return oldName; 130 } 131 132 135 public void setId(int id) { 136 this.id = id; 137 } 138 139 142 public void setOldName(String oldName) { 143 this.oldName = oldName; 144 this.oldNameSet = true; 145 } 146 } | Popular Tags |