Skip to content

Commit 49ca35d

Browse files
committed
#23 Use native types as model's field types
Native types should be favored over boxed types for two reasons: 1. Boxed types introduce more verbose code. 2. Boxed types introduce possible NPE. Since native types reduces code clutter because they have a default value and they also can not be null, we switched to native type fields. Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 5f2ecf2 commit 49ca35d

15 files changed

+55
-65
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/model/Endpoint.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class Endpoint implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
2424
private String protocol;
@@ -30,7 +30,7 @@ public final class Endpoint implements Model {
3030
private String fullyQualifiedDomainName;
3131

3232
@JsonProperty
33-
private Long port;// FIXME: Use native type here.
33+
private long port;
3434

3535
@JsonProperty
3636
private String path;
@@ -42,10 +42,10 @@ public final class Endpoint implements Model {
4242
private String fragment;
4343

4444
@JsonProperty
45-
private Long product;// FIXME: Use native type here.
45+
private long product;
4646

4747
@JsonProperty
48-
private Boolean mitigated;// FIXME: Use native type here.
48+
private boolean mitigated;
4949

5050
@Override
5151
public boolean equalsQueryString(Map<String, Object> queryParams) {

src/main/java/io/securecodebox/persistence/defectdojo/model/Engagement.java

+9-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public final class Engagement implements Model {
2828
private String name;
2929

3030
@JsonProperty
31-
private Long product;// FIXME: Use native type here.
31+
private long product;
3232

3333
@JsonProperty("target_start")
3434
private String targetStart;
@@ -37,7 +37,7 @@ public final class Engagement implements Model {
3737
private String targetEnd;
3838

3939
@JsonProperty
40-
private Long lead;// FIXME: Use native type here.
40+
private long lead;
4141

4242
@JsonProperty("engagement_type")
4343
@Builder.Default
@@ -63,13 +63,13 @@ public final class Engagement implements Model {
6363
private String repo;
6464

6565
@JsonProperty("build_server")
66-
private Long buildServer; // FIXME: Use native type here.
66+
private long buildServer;
6767

6868
@JsonProperty("source_code_management_server")
69-
private Long scmServer; // FIXME: Use natvive type here.
69+
private long scmServer;
7070

7171
@JsonProperty("orchestration_engine")
72-
private Long orchestrationEngine; // FIXME: Use natvive type here.
72+
private long orchestrationEngine;
7373

7474
@JsonProperty
7575
private String description;
@@ -78,20 +78,16 @@ public final class Engagement implements Model {
7878
private boolean deduplicationOnEngagement;
7979

8080
@JsonProperty("threat_model")
81-
@Builder.Default // FIXME: Use native type here.
82-
private Boolean threatModel = false;
81+
private boolean threatModel;
8382

8483
@JsonProperty("api_test")
85-
@Builder.Default // FIXME: Use native type here.
86-
private Boolean apiTest = false;
84+
private boolean apiTest;
8785

8886
@JsonProperty("pen_test")
89-
@Builder.Default // FIXME: Use native type here.
90-
private Boolean penTest = false;
87+
private boolean penTest;
9188

9289
@JsonProperty("check_list")
93-
@Builder.Default // FIXME: Use native type here.
94-
private Boolean checkList = false;
90+
private boolean checkList;
9591

9692
@JsonProperty
9793
private String version;

src/main/java/io/securecodebox/persistence/defectdojo/model/Finding.java

+9-16
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@JsonInclude(JsonInclude.Include.NON_NULL)
2424
public final class Finding implements Model {
2525
@JsonProperty
26-
private Long id;// FIXME: Use native type here.
26+
private long id;
2727

2828
@JsonProperty
2929
@NonNull
@@ -43,7 +43,7 @@ public final class Finding implements Model {
4343

4444
@JsonProperty
4545
@NonNull
46-
private Long test;// FIXME: Use native type here.
46+
private long test;
4747

4848
@JsonProperty
4949
private String mitigation;
@@ -53,37 +53,30 @@ public final class Finding implements Model {
5353

5454
@JsonProperty
5555
@NonNull
56-
@Builder.Default
57-
private Boolean active = true;// FIXME: Use native type here.
56+
private boolean active;
5857

5958
@JsonProperty
6059
@NonNull
61-
@Builder.Default
62-
private Boolean verified = true;// FIXME: Use native type here.
60+
private boolean verified;
6361

6462
@JsonProperty("risk_accepted")
6563
@NonNull
66-
@Builder.Default
67-
private Boolean riskAccepted = false;// FIXME: Use native type here.
64+
private boolean riskAccepted;
6865

6966
@JsonProperty("out_of_scope")
7067
@NonNull
71-
@Builder.Default
72-
private Boolean outOfScope = false;// FIXME: Use native type here.
68+
private boolean outOfScope;
7369

7470
@JsonProperty
7571
@NonNull
76-
@Builder.Default
77-
private Boolean duplicate = false;// FIXME: Use native type here.
72+
private boolean duplicate;
7873

7974
@JsonProperty("duplicate_finding")
80-
@Builder.Default
81-
private Long duplicateFinding = null;// FIXME: Use native type here.
75+
private long duplicateFinding;
8276

8377
@JsonProperty("false_p")
8478
@NonNull
85-
@Builder.Default
86-
private Boolean falsePositive = false;// FIXME: Use native type here.
79+
private boolean falsePositive;
8780

8881
@JsonProperty("component_name")
8982
private String componentName;

src/main/java/io/securecodebox/persistence/defectdojo/model/Group.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@JsonInclude(JsonInclude.Include.NON_NULL)
2020
public final class Group implements Model {
2121
@JsonProperty
22-
private Long id;// FIXME: Use native type here.
22+
private long id;
2323

2424
@JsonProperty
2525
@NonNull

src/main/java/io/securecodebox/persistence/defectdojo/model/GroupMember.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class GroupMember implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty("group_id")
24-
private Long group;// FIXME: Use native type here.
24+
private long group;
2525

2626
@JsonProperty("user_id")
27-
private Long user;// FIXME: Use native type here.
27+
private long user;
2828

2929
@JsonProperty
30-
private Long role;// FIXME: Use native type here.
30+
private long role;
3131

3232
@Override
3333
public boolean equalsQueryString(Map<String, Object> queryParams) {

src/main/java/io/securecodebox/persistence/defectdojo/model/Product.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@JsonInclude(JsonInclude.Include.NON_NULL)
2020
public final class Product implements Model {
2121
@JsonProperty
22-
private Long id;// FIXME: Use native type here.
22+
private long id;
2323

2424
@JsonProperty
2525
private String name;
@@ -31,19 +31,19 @@ public final class Product implements Model {
3131
private String description;
3232

3333
@JsonProperty("findings_count")
34-
private Long findingsCount;// FIXME: Use native type here.
34+
private long findingsCount;
3535

3636
@JsonProperty("authorized_users")
3737
private List<String> authorizedUsers;
3838

3939
@JsonProperty("prod_type")
40-
private Long productType;// FIXME: Use native type here.
40+
private long productType;
4141

4242
@JsonProperty("enable_simple_risk_acceptance")
43-
private Boolean enableSimpleRiskAcceptance;// FIXME: Use native type here.
43+
private boolean enableSimpleRiskAcceptance;
4444

4545
@JsonProperty("enable_full_risk_acceptance")
46-
private Boolean enableFullRiskAcceptance;// FIXME: Use native type here.
46+
private boolean enableFullRiskAcceptance;
4747

4848
@JsonProperty("authorization_groups")
4949
private List<Long> authorizationGroups;

src/main/java/io/securecodebox/persistence/defectdojo/model/ProductGroup.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class ProductGroup implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
24-
private Long product;// FIXME: Use native type here.
24+
private long product;
2525

2626
@JsonProperty
27-
private Long group;// FIXME: Use native type here.
27+
private long group;
2828

2929
@JsonProperty
30-
private Long role;// FIXME: Use native type here.
30+
private long role;
3131

3232
@Override
3333
public boolean equalsQueryString(Map<String, Object> queryParams) {

src/main/java/io/securecodebox/persistence/defectdojo/model/ProductType.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class ProductType implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
2424
@NonNull
2525
private String name;
2626

2727
@JsonProperty("critical_product")
28-
private Boolean criticalProduct;// FIXME: Use native type here.
28+
private boolean criticalProduct;
2929

3030
@JsonProperty("key_product")
31-
private Boolean keyProduct;// FIXME: Use native type here.
31+
private boolean keyProduct;
3232

3333
@Override
3434
public boolean equalsQueryString(Map<String, Object> queryParams) {

src/main/java/io/securecodebox/persistence/defectdojo/model/Response.java

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.util.List;
1111

12+
// TODO: Why we do not have as many annotations as the other models here?
1213
@Data
1314
public final class Response<T> {
1415
@JsonProperty

src/main/java/io/securecodebox/persistence/defectdojo/model/RiskAcceptance.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@JsonInclude(JsonInclude.Include.NON_NULL)
2020
public final class RiskAcceptance implements Model {
2121
@JsonProperty
22-
private Long id;// FIXME: Use native type here.
22+
private long id;
2323

2424
@JsonProperty
2525
private String recommendation;
@@ -54,7 +54,7 @@ public final class RiskAcceptance implements Model {
5454
private OffsetDateTime updatedAt;
5555

5656
@JsonProperty
57-
private Long owner;// FIXME: Use native type here.
57+
private long owner;
5858

5959
@Override
6060
public boolean equalsQueryString(Map<String, Object> queryParams) {

src/main/java/io/securecodebox/persistence/defectdojo/model/Test.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@JsonInclude(JsonInclude.Include.NON_NULL)
2121
public final class Test implements Model {
2222
@JsonProperty
23-
private Long id;// FIXME: Use native type here.
23+
private long id;
2424

2525
@JsonProperty
2626
private String title;
@@ -39,16 +39,16 @@ public final class Test implements Model {
3939
private List<String> tags = new LinkedList<>();
4040

4141
@JsonProperty("test_type")
42-
private Long testType;// FIXME: Use native type here.
42+
private long testType;
4343

4444
@JsonProperty
45-
private Long lead;// FIXME: Use native type here.
45+
private long lead;
4646

4747
@JsonProperty("percent_complete")
48-
private Long percentComplete;// FIXME: Use native type here.
48+
private long percentComplete;
4949

5050
@JsonProperty
51-
private Long engagement;// FIXME: Use native type here.
51+
private long engagement;
5252

5353
@JsonProperty
5454
private String version;
@@ -59,7 +59,7 @@ public final class Test implements Model {
5959
*/
6060
@JsonProperty
6161
@Builder.Default
62-
private Long environment = 1L;// FIXME: Use native type here.
62+
private long environment = 1L;
6363

6464
@Override
6565
public boolean equalsQueryString(Map<String, Object> queryParams) {

src/main/java/io/securecodebox/persistence/defectdojo/model/TestType.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class TestType implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
2424
@NonNull
2525
private String name;
2626

2727
@JsonProperty("static_tool")
28-
private Boolean staticTool;// FIXME: Use native type here.
28+
private boolean staticTool;
2929

3030
@JsonProperty("dynamic_tool")
31-
private Boolean dynamicTool;// FIXME: Use native type here.
31+
private boolean dynamicTool;
3232

3333

3434
@Override

src/main/java/io/securecodebox/persistence/defectdojo/model/ToolConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class ToolConfig implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
2424
String url;
@@ -28,7 +28,7 @@ public final class ToolConfig implements Model {
2828
String name;
2929

3030
@JsonProperty("tool_type")
31-
private Long toolType;// FIXME: Use native type here.
31+
private long toolType;
3232

3333
@JsonProperty("configuration_url")
3434
String configUrl;

src/main/java/io/securecodebox/persistence/defectdojo/model/ToolType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class ToolType implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
2424
@NonNull

src/main/java/io/securecodebox/persistence/defectdojo/model/User.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@JsonInclude(JsonInclude.Include.NON_NULL)
1919
public final class User implements Model {
2020
@JsonProperty
21-
private Long id;// FIXME: Use native type here.
21+
private long id;
2222

2323
@JsonProperty
2424
@NonNull

0 commit comments

Comments
 (0)