1 19 package org.apache.cayenne.map; 20 21 import java.io.Serializable ; 22 import java.util.Arrays ; 23 import java.util.Collection ; 24 import java.util.Collections ; 25 import java.util.HashSet ; 26 import java.util.Set ; 27 28 34 public class CallbackDescriptor implements Serializable { 35 36 37 38 protected int callbackType; 39 protected Set callbackMethods; 40 41 public CallbackDescriptor(int callbackType) { 42 setCallbackType(callbackType); 43 this.callbackMethods = new HashSet (3); 44 } 45 46 49 public void clear() { 50 callbackMethods.clear(); 51 } 52 53 56 public Collection getCallbackMethods() { 57 return Collections.unmodifiableCollection(callbackMethods); 58 } 59 60 public void addCallbackMethod(String methodName) { 61 callbackMethods.add(methodName); 62 } 63 64 public void removeCallbackMethod(String methodName) { 65 callbackMethods.remove(methodName); 66 } 67 68 public int getCallbackType() { 69 return callbackType; 70 } 71 72 void setCallbackType(int callbackType) { 73 if (Arrays.binarySearch(CallbackMap.CALLBACKS, callbackType) != callbackType) { 74 throw new IllegalArgumentException ("Invalid callback: " + callbackType); 75 } 76 77 this.callbackType = callbackType; 78 } 79 } 80 | Popular Tags |