unicon.matthews.oneroster.service.repository.MongoAcademicSession   A
last analyzed

Complexity

Total Complexity 27

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 116
rs 10
eloc 81
wmc 27

14 Methods

Rating   Name   Duplication   Size   Complexity  
F equals(Object) 0 34 16
A Builder.withAcademicSession(AcademicSession) 0 3 1
A Builder.withOrgId(String) 0 3 1
A getAcademicSession() 0 2 1
A getAcademicSessionSourcedId() 0 2 1
A getTenantId() 0 2 1
A toString() 0 3 1
A Builder.withId(String) 0 3 1
A Builder.withTenantId(String) 0 3 1
A getOrgId() 0 2 1
A getId() 0 2 1
A Builder.withAcademicSessionSourcedId(String) 0 3 1
A Builder.build() 0 6 3
A hashCode() 0 9 5
1
package unicon.matthews.oneroster.service.repository;
2
3
import java.io.Serializable;
4
import java.time.LocalDate;
0 ignored issues
show
Unused Code introduced by
Remove this unused import 'java.time.LocalDate'.
Loading history...
5
import org.apache.commons.lang3.StringUtils;
6
import org.apache.commons.lang3.builder.ToStringBuilder;
7
import org.apache.commons.lang3.builder.ToStringStyle;
8
import org.springframework.data.annotation.Id;
9
import org.springframework.data.mongodb.core.mapping.Document;
10
11
import unicon.matthews.oneroster.AcademicSession;
12
13
/**
14
 * @author stalele
15
 *
16
 */
17
@Document
18
public class MongoAcademicSession implements Serializable{
19
20
  private static final long serialVersionUID = 1L;
21
  
22
  @Id private String id;
23
  private String orgId;
24
  private String tenantId;
25
  private AcademicSession academicSession;
0 ignored issues
show
Bug Best Practice introduced by
Fields like academicSession in a serializable class should either be transient or serializable.
Loading history...
26
  private String academicSessionSourcedId;
27
  
28
  public String getAcademicSessionSourcedId() {
29
    return academicSessionSourcedId;
30
  }
31
  public String getId() {
32
    return id;
33
  }
34
35
  public String getOrgId() {
36
    return orgId;
37
  }
38
39
  public String getTenantId() {
40
    return tenantId;
41
  }
42
43
  public AcademicSession getAcademicSession() {
44
    return academicSession;
45
  }
46
  
47
  @Override
48
  public String toString() {
49
    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
50
  }
51
52
  @Override
53
  public int hashCode() {
54
    final int prime = 31;
55
    int result = 1;
56
    result = prime * result + ((academicSession == null) ? 0 : academicSession.hashCode());
57
    result = prime * result + ((id == null) ? 0 : id.hashCode());
58
    result = prime * result + ((orgId == null) ? 0 : orgId.hashCode());
59
    result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode());
60
    return result;
61
  }
62
63
  @Override
64
  public boolean equals(Object obj) {
65
    if (this == obj)
66
      return true;
67
    if (obj == null)
68
      return false;
69
    if (getClass() != obj.getClass())
70
      return false;
71
    MongoAcademicSession other = (MongoAcademicSession) obj;
72
    if (academicSession == null) {
73
      if (other.academicSession != null)
74
        return false;
75
    }
76
    else if (!academicSession.equals(other.academicSession))
77
      return false;
78
    if (id == null) {
79
      if (other.id != null)
80
        return false;
81
    }
82
    else if (!id.equals(other.id))
83
      return false;
84
    if (orgId == null) {
85
      if (other.orgId != null)
86
        return false;
87
    }
88
    else if (!orgId.equals(other.orgId))
89
      return false;
90
    if (tenantId == null) {
91
      if (other.tenantId != null)
92
        return false;
93
    }
94
    else if (!tenantId.equals(other.tenantId))
95
      return false;
96
    return true;
97
  }
98
99
  public static class Builder {
100
    private MongoAcademicSession _mongoAcademicSession = new MongoAcademicSession();
101
102
    public Builder withId(String id) {
103
      _mongoAcademicSession.id = id;
104
      return this;
105
    }
106
107
    public Builder withOrgId(String orgId) {
108
      _mongoAcademicSession.orgId = orgId;
109
      return this;
110
    }
111
112
    public Builder withTenantId(String tenantId) {
113
      _mongoAcademicSession.tenantId = tenantId;
114
      return this;
115
    }
116
117
    public Builder withAcademicSession(AcademicSession academicSession) {
118
      _mongoAcademicSession.academicSession = academicSession;
119
      return this;
120
    }
121
122
    public Builder withAcademicSessionSourcedId(String sourcedId) {
123
      _mongoAcademicSession.academicSessionSourcedId = sourcedId;
124
      return this;
125
    }
126
127
    public MongoAcademicSession build() {
128
      if (StringUtils.isBlank(_mongoAcademicSession.orgId) || StringUtils.isBlank(_mongoAcademicSession.tenantId)) {
129
        throw new IllegalStateException(_mongoAcademicSession.toString());
130
      }
131
132
      return _mongoAcademicSession;
133
    }
134
  }
135
}
136