File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\jenkins\model\lazy\BuildReference.java.html

1 package jenkins.model.lazy;
2
3 import java.lang.ref.SoftReference;
4
5 /**
6 * {@link SoftReference} to a build object.
7 *
8 * <p>
9 * To be able to re-retrieve the referent in case it is lost, this class
10 * remembers its ID (the job name is provided by the context because a {@link BuildReference}
11 * belongs to one and only {@link AbstractLazyLoadRunMap}.)
12 *
13 * <p>
14 * We use this ID for equality/hashCode so that we can have a collection of {@link BuildReference}
15 * and find things in it.
16 *
17 * @author Kohsuke Kawaguchi
18 * @since 1.485
19 */
20 public final class BuildReference<R> extends SoftReference<R> {
21 final String id;
22
23 public BuildReference(String id, R referent) {
24 super(referent);
25 this.id = id;
26 }
27
28 @Override
29 public boolean equals(Object o) {
30 if (this == o) return true;
31 if (o == null || getClass() != o.getClass()) return false;
32
33 BuildReference that = (BuildReference) o;
34 return id.equals(that.id);
35
36 }
37
38 @Override
39 public int hashCode() {
40 return id.hashCode();
41 }
42 }
43