getDataSyncs()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 2
rs 10
eloc 2
1
/**
2
 * 
3
 */
4
package unicon.matthews.oneroster.service.repository;
5
6
import java.io.Serializable;
7
import java.util.Set;
8
9
import org.apache.commons.lang3.StringUtils;
10
import org.apache.commons.lang3.builder.ToStringBuilder;
11
import org.apache.commons.lang3.builder.ToStringStyle;
12
import org.springframework.data.annotation.Id;
13
import org.springframework.data.mongodb.core.mapping.Document;
14
15
import unicon.matthews.entity.DataSync;
16
import unicon.matthews.oneroster.Org;
17
18
/**
19
 * @author ggilbert
20
 *
21
 */
22
@Document
23
public class MongoOrg implements Serializable {
24
  private static final long serialVersionUID = 1L;
25
26
  @Id private String id;
27
28
  private String apiKey;
29
  private String apiSecret;
30
  private String tenantId;
31
  
32
  private Org org;
0 ignored issues
show
Bug Best Practice introduced by
Fields like org in a serializable class should either be transient or serializable.
Loading history...
33
  
34
  private Set<DataSync> dataSyncs;
35
  
36
  private MongoOrg() {}
37
38
  public String getId() {
39
    return id;
40
  }
41
42
  public String getApiKey() {
43
    return apiKey;
44
  }
45
46
  public String getApiSecret() {
47
    return apiSecret;
48
  }
49
50
  public String getTenantId() {
51
    return tenantId;
52
  }
53
54
  public Org getOrg() {
55
    return org;
56
  }
57
  
58
  public Set<DataSync> getDataSyncs() {
59
    return dataSyncs;
60
  }
61
62
  @Override
63
  public String toString() {
64
    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
65
  }
66
67
  @Override
68
  public int hashCode() {
69
    final int prime = 31;
70
    int result = 1;
71
    result = prime * result + ((apiKey == null) ? 0 : apiKey.hashCode());
72
    result = prime * result + ((apiSecret == null) ? 0 : apiSecret.hashCode());
73
    result = prime * result + ((dataSyncs == null) ? 0 : dataSyncs.hashCode());
74
    result = prime * result + ((id == null) ? 0 : id.hashCode());
75
    result = prime * result + ((org == null) ? 0 : org.hashCode());
76
    result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode());
77
    return result;
78
  }
79
80
  @Override
81
  public boolean equals(Object obj) {
82
    if (this == obj)
83
      return true;
84
    if (obj == null)
85
      return false;
86
    if (getClass() != obj.getClass())
87
      return false;
88
    MongoOrg other = (MongoOrg) obj;
89
    if (apiKey == null) {
90
      if (other.apiKey != null)
91
        return false;
92
    } else if (!apiKey.equals(other.apiKey))
93
      return false;
94
    if (apiSecret == null) {
95
      if (other.apiSecret != null)
96
        return false;
97
    } else if (!apiSecret.equals(other.apiSecret))
98
      return false;
99
    if (dataSyncs == null) {
100
      if (other.dataSyncs != null)
101
        return false;
102
    } else if (!dataSyncs.equals(other.dataSyncs))
103
      return false;
104
    if (id == null) {
105
      if (other.id != null)
106
        return false;
107
    } else if (!id.equals(other.id))
108
      return false;
109
    if (org == null) {
110
      if (other.org != null)
111
        return false;
112
    } else if (!org.equals(other.org))
113
      return false;
114
    if (tenantId == null) {
115
      if (other.tenantId != null)
116
        return false;
117
    } else if (!tenantId.equals(other.tenantId))
118
      return false;
119
    return true;
120
  }
121
122
  public static class Builder {
123
    private MongoOrg _mongoOrg = new MongoOrg();
124
    
125
    public Builder withId(String id) {
126
      _mongoOrg.id = id;
127
      return this;
128
    }
129
    
130
    public Builder withApiKey(String apiKey) {
131
      _mongoOrg.apiKey = apiKey;
132
      return this;
133
    }
134
    
135
    public Builder withApiSecret(String apiSecret) {
136
      _mongoOrg.apiSecret = apiSecret;
137
      return this;
138
    }
139
    
140
    public Builder withTenantId(String tenantId) {
141
      _mongoOrg.tenantId = tenantId;
142
      return this;
143
    }
144
    
145
    public Builder withOrg(Org org) {
146
      _mongoOrg.org = org;
147
      return this;
148
    }
149
    
150
    public Builder withDataSyncs(Set<DataSync> dataSyncs) {
151
      _mongoOrg.dataSyncs = dataSyncs;
152
      return this;
153
    }
154
    
155
    public MongoOrg build() {
156
      
157
      if (StringUtils.isBlank(_mongoOrg.tenantId) 
158
          || StringUtils.isBlank(_mongoOrg.apiKey) 
159
          || StringUtils.isBlank(_mongoOrg.apiSecret)
160
          || _mongoOrg.org == null)
161
      {
162
        throw new IllegalStateException(_mongoOrg.toString());
163
      }
164
      
165
      return _mongoOrg;
166
    }
167
  }
168
}
169