diff --git a/core/src/main/java/hudson/util/DescribableList.java b/core/src/main/java/hudson/util/DescribableList.java index 8ec6418386fd..61852f84964f 100644 --- a/core/src/main/java/hudson/util/DescribableList.java +++ b/core/src/main/java/hudson/util/DescribableList.java @@ -99,6 +99,25 @@ public void replace(T item) throws IOException { onModified(); } + /** + * Binds items in the collection to URL. + */ + public T getDynamic(String id) { + // by ID + for (T t : data) + if(t.getDescriptor().getId().equals(id)) + return t; + + // by position + try { + return data.get(Integer.parseInt(id)); + } catch (NumberFormatException e) { + // fall through + } + + return null; + } + public T get(D descriptor) { for (T t : data) if(t.getDescriptor()==descriptor)