KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > model > JobPropertyDescriptor


1 package hudson.model;
2
3 import java.util.List JavaDoc;
4 import java.util.ArrayList JavaDoc;
5
6 /**
7  * {@link Descriptor} for {@link JobProperty}.
8  *
9  * @author Kohsuke Kawaguchi
10  * @see Jobs#PROPERTIES
11  * @since 1.72
12  */

13 public abstract class JobPropertyDescriptor extends Descriptor<JobProperty<?>> {
14     protected JobPropertyDescriptor(Class JavaDoc<? extends JobProperty<?>> clazz) {
15         super(clazz);
16     }
17
18     /**
19      * Returns true if this {@link JobProperty} type is applicable to the
20      * given job type.
21      *
22      * <p>
23      * Normally, this method is implemented like
24      * {@code return AbstractProject.class.isAssignableFrom(jobType)}
25      * where "<tt>AbstractProject</tt>" is the J of {@link JobProperty}<tt>&lt;J></tt>.
26      *
27      * @return
28      * true to indicate applicable, in which case the property will be
29      * displayed in the configuration screen of this job.
30      */

31     public abstract boolean isApplicable(Class JavaDoc<? extends Job> jobType);
32
33     /**
34      * Gets the {@link JobPropertyDescriptor}s applicable for a given job type.
35      */

36     public static List JavaDoc<JobPropertyDescriptor> getPropertyDescriptors(Class JavaDoc<? extends Job> clazz) {
37         List JavaDoc<JobPropertyDescriptor> r = new ArrayList JavaDoc<JobPropertyDescriptor>();
38         for (JobPropertyDescriptor p : Jobs.PROPERTIES)
39             if(p.isApplicable(clazz))
40                 r.add(p);
41         return r;
42     }
43 }
44
Popular Tags