1 package hudson.model; 2 3 import org.kohsuke.stapler.StaplerRequest; 4 import org.kohsuke.stapler.StaplerResponse; 5 6 import java.util.List ; 7 import java.util.Vector ; 8 9 14 public abstract class Actionable extends AbstractModelObject { 15 18 private List <Action> actions; 19 20 29 public synchronized List <Action> getActions() { 30 if(actions==null) 31 actions = new Vector <Action>(); 32 return actions; 33 } 34 35 public Action getAction(int index) { 36 if(actions==null) return null; 37 return actions.get(index); 38 } 39 40 public <T extends Action> T getAction(Class <T> type) { 41 for (Action a : getActions()) 42 if (type.isInstance(a)) 43 return type.cast(a); 44 return null; 45 } 46 47 public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { 48 for (Action a : getActions()) { 49 if(a.getUrlName().equals(token)) 50 return a; 51 } 52 return null; 53 } 54 } 55 | Popular Tags |