Skip to content

Commit

Permalink
exposing items to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Jun 29, 2012
1 parent 96442cd commit 7bcc810
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/src/main/java/hudson/util/DescribableList.java
Expand Up @@ -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)
Expand Down

0 comments on commit 7bcc810

Please sign in to comment.