Permalink
Browse files

exposing items to URL

  • Loading branch information...
1 parent 96442cd commit 7bcc8107e2200fb9cd82788dbef471c612d9771f @kohsuke kohsuke committed Jun 29, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 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)

0 comments on commit 7bcc810

Please sign in to comment.