BrightSide Workbench Full Report + Source Code
IssueItem.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.dossier.graph;
20 
21 import java.util.Objects;
22 import org.turro.dossier.entity.Issue;
23 import org.turro.jpa.Dao;
24 import org.turro.util.Cached;
25 
30 public class IssueItem {
31 
32  private final Long issueId;
33 
34  public IssueItem(Cached<Dao> dao, Long issueId) {
35  this.issueId = issueId;
36  this.issue = Cached.instance(() -> dao.get().find(Issue.class, this.issueId));
37  }
38 
39  public IssueItem(Issue issue) {
40  this.issueId = issue.getId();
41  this.issue = Cached.instance(issue);
42  }
43 
44  public Long getIssueId() {
45  return issueId;
46  }
47 
48  /* Issue */
49 
50  private final Cached<Issue> issue;
51 
52  public Issue getIssue() {
53  return issue.get();
54  }
55 
56  /* Utils */
57 
58  @Override
59  public int hashCode() {
60  int hash = 7;
61  hash = 17 * hash + Objects.hashCode(this.issueId);
62  return hash;
63  }
64 
65  @Override
66  public boolean equals(Object obj) {
67  if (this == obj) {
68  return true;
69  }
70  if (obj == null) {
71  return false;
72  }
73  if (getClass() != obj.getClass()) {
74  return false;
75  }
76  final IssueItem other = (IssueItem) obj;
77  return Objects.equals(this.issueId, other.issueId);
78  }
79 
80 }
boolean equals(Object obj)
Definition: IssueItem.java:66
IssueItem(Cached< Dao > dao, Long issueId)
Definition: IssueItem.java:34