Skip to content

Commit 8e3c7ce

Browse files
committed
#23 Reformat Java code
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent b2c66a6 commit 8e3c7ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1670
-1756
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/ScanType.java

Lines changed: 196 additions & 196 deletions
Large diffs are not rendered by default.

src/main/java/io/securecodebox/persistence/defectdojo/config/Config.java

Lines changed: 121 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
package io.securecodebox.persistence.defectdojo.config;
66

77
import io.securecodebox.persistence.defectdojo.exception.ConfigException;
8-
import lombok.*;
8+
import lombok.EqualsAndHashCode;
9+
import lombok.Getter;
10+
import lombok.NonNull;
11+
import lombok.ToString;
912

1013
/**
1114
* Configures the DefectDojo client
@@ -14,133 +17,133 @@
1417
@ToString
1518
@EqualsAndHashCode
1619
public final class Config {
17-
/**
18-
* Default for {@link #maxPageCountForGets}
19-
*/
20-
static final int DEFAULT_MAX_PAGE_COUNT_FOR_GETS = 100;
21-
/**
22-
* Null pattern object.
23-
*/
24-
public static final Config NULL = new Config("", "", DEFAULT_MAX_PAGE_COUNT_FOR_GETS);
25-
26-
/**
27-
* URL of the host which serves the DefectDojo API.
28-
* <p>
29-
* It is only allowed to configure the base URL (e.g. {@literal "https://defectdojo.securecodebox.io/"} without
30-
* any path. The path to the concrete API endpoints are maintained by this client library itself.
31-
* </p>
32-
*/
33-
@NonNull
34-
private final String url;
35-
36-
/**
37-
* API key to authorize against the DefectDojo API.
38-
*/
39-
@NonNull
40-
private final String apiKey;
41-
42-
/**
43-
* How many pages of objects are fetched from the DefectDojo API
44-
* <p>
45-
* This setting is to avoid out of memory scenarios.
46-
* </p>
47-
* <p>
48-
* Defaults to {@link #DEFAULT_MAX_PAGE_COUNT_FOR_GETS}.
49-
* </p>
50-
*/
51-
private final int maxPageCountForGets;
52-
53-
/**
54-
* Convenience constructor which sets {@link #DEFAULT_MAX_PAGE_COUNT_FOR_GETS}
55-
*
56-
* @param url not {@code null}
57-
* @param apiKey not {@code null}
58-
*/
59-
public Config(final @NonNull String url, final @NonNull String apiKey) {
60-
this(url, apiKey, DEFAULT_MAX_PAGE_COUNT_FOR_GETS);
20+
/**
21+
* Default for {@link #maxPageCountForGets}
22+
*/
23+
static final int DEFAULT_MAX_PAGE_COUNT_FOR_GETS = 100;
24+
/**
25+
* Null pattern object.
26+
*/
27+
public static final Config NULL = new Config("", "", DEFAULT_MAX_PAGE_COUNT_FOR_GETS);
28+
29+
/**
30+
* URL of the host which serves the DefectDojo API.
31+
* <p>
32+
* It is only allowed to configure the base URL (e.g. {@literal "https://defectdojo.securecodebox.io/"} without
33+
* any path. The path to the concrete API endpoints are maintained by this client library itself.
34+
* </p>
35+
*/
36+
@NonNull
37+
private final String url;
38+
39+
/**
40+
* API key to authorize against the DefectDojo API.
41+
*/
42+
@NonNull
43+
private final String apiKey;
44+
45+
/**
46+
* How many pages of objects are fetched from the DefectDojo API
47+
* <p>
48+
* This setting is to avoid out of memory scenarios.
49+
* </p>
50+
* <p>
51+
* Defaults to {@link #DEFAULT_MAX_PAGE_COUNT_FOR_GETS}.
52+
* </p>
53+
*/
54+
private final int maxPageCountForGets;
55+
56+
/**
57+
* Convenience constructor which sets {@link #DEFAULT_MAX_PAGE_COUNT_FOR_GETS}
58+
*
59+
* @param url not {@code null}
60+
* @param apiKey not {@code null}
61+
*/
62+
public Config(final @NonNull String url, final @NonNull String apiKey) {
63+
this(url, apiKey, DEFAULT_MAX_PAGE_COUNT_FOR_GETS);
64+
}
65+
66+
/**
67+
* Dedicated constructor
68+
*
69+
* @param url not {@code null}
70+
* @param apiKey not {@code null}
71+
* @param maxPageCountForGets not less than 1
72+
*/
73+
public Config(final @NonNull String url, final @NonNull String apiKey, final int maxPageCountForGets) {
74+
super();
75+
this.url = url;
76+
this.apiKey = apiKey;
77+
this.maxPageCountForGets = validateIsGreaterZero(maxPageCountForGets, "maxPageCountForGets");
78+
}
79+
80+
private static int validateIsGreaterZero(final int number, final String name) {
81+
if (number < 1) {
82+
throw new IllegalArgumentException(String.format("%s must be greater than 0!", name));
6183
}
6284

63-
/**
64-
* Dedicated constructor
65-
*
66-
* @param url not {@code null}
67-
* @param apiKey not {@code null}
68-
* @param maxPageCountForGets not less than 1
69-
*/
70-
public Config(final @NonNull String url, final @NonNull String apiKey, final int maxPageCountForGets) {
71-
super();
72-
this.url = url;
73-
this.apiKey = apiKey;
74-
this.maxPageCountForGets = validateIsGreaterZero(maxPageCountForGets, "maxPageCountForGets");
75-
}
76-
77-
private static int validateIsGreaterZero(final int number, final String name) {
78-
if (number < 1) {
79-
throw new IllegalArgumentException(String.format("%s must be greater than 0!", name));
80-
}
81-
82-
return number;
85+
return number;
86+
}
87+
88+
/**
89+
* Creates config from environment variables
90+
*
91+
* @return never {@code null}
92+
*/
93+
public static Config fromEnv() {
94+
final var url = findRequiredEnvVar(EnvVars.DEFECTDOJO_URL);
95+
final var apiKey = findRequiredEnvVar(EnvVars.DEFECTDOJO_APIKEY);
96+
final int maxPageCountForGets;
97+
98+
if (hasEnvVar(EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS)) {
99+
try {
100+
maxPageCountForGets = Integer.parseInt(findEnvVar(EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS));
101+
} catch (final NumberFormatException e) {
102+
throw new ConfigException(String.format("Given value for environment variable '%s' is not a valid number! Given was '%s'.", EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS.literal, findEnvVar(EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS)),
103+
e);
104+
}
105+
} else {
106+
maxPageCountForGets = DEFAULT_MAX_PAGE_COUNT_FOR_GETS;
83107
}
84108

85-
/**
86-
* Creates config from environment variables
87-
*
88-
* @return never {@code null}
89-
*/
90-
public static Config fromEnv() {
91-
final var url = findRequiredEnvVar(EnvVars.DEFECTDOJO_URL);
92-
final var apiKey = findRequiredEnvVar(EnvVars.DEFECTDOJO_APIKEY);
93-
final int maxPageCountForGets;
94-
95-
if (hasEnvVar(EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS)) {
96-
try {
97-
maxPageCountForGets = Integer.parseInt(findEnvVar(EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS));
98-
} catch (final NumberFormatException e) {
99-
throw new ConfigException(String.format("Given value for environment variable '%s' is not a valid number! Given was '%s'.", EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS.literal, findEnvVar(EnvVars.DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS)),
100-
e);
101-
}
102-
} else {
103-
maxPageCountForGets = DEFAULT_MAX_PAGE_COUNT_FOR_GETS;
104-
}
105-
106-
return new Config(url, apiKey, maxPageCountForGets);
107-
}
109+
return new Config(url, apiKey, maxPageCountForGets);
110+
}
108111

109-
private static boolean hasEnvVar(final @NonNull EnvVars name) {
110-
return findEnvVar(name) != null;
111-
}
112+
private static boolean hasEnvVar(final @NonNull EnvVars name) {
113+
return findEnvVar(name) != null;
114+
}
112115

113-
private static String findEnvVar(final @NonNull EnvVars name) {
114-
return System.getenv(name.literal);
115-
}
116+
private static String findEnvVar(final @NonNull EnvVars name) {
117+
return System.getenv(name.literal);
118+
}
116119

117-
private static String findRequiredEnvVar(final @NonNull EnvVars name) {
118-
final var envVar = System.getenv(name.literal);
120+
private static String findRequiredEnvVar(final @NonNull EnvVars name) {
121+
final var envVar = System.getenv(name.literal);
119122

120-
if (envVar == null) {
121-
throw new ConfigException(String.format("Missing environment variable '%s'!", name.literal));
122-
}
123-
return envVar;
123+
if (envVar == null) {
124+
throw new ConfigException(String.format("Missing environment variable '%s'!", name.literal));
124125
}
125-
126+
return envVar;
127+
}
128+
129+
/**
130+
* Enumerates the available environment variables to configure the client
131+
*/
132+
public enum EnvVars {
133+
DEFECTDOJO_URL("DEFECTDOJO_URL"),
134+
DEFECTDOJO_APIKEY("DEFECTDOJO_APIKEY"),
135+
DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS("DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS");
126136
/**
127-
* Enumerates the available environment variables to configure the client
137+
* Literal name of configuration environment name
138+
* <p>
139+
* We use an own value to hold the actual value, so that refactoring the enum name does
140+
* not break the published API of env var names.
141+
* </p>
128142
*/
129-
public enum EnvVars {
130-
DEFECTDOJO_URL("DEFECTDOJO_URL"),
131-
DEFECTDOJO_APIKEY("DEFECTDOJO_APIKEY"),
132-
DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS("DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS");
133-
/**
134-
* Literal name of configuration environment name
135-
* <p>
136-
* We use an own value to hold the actual value, so that refactoring the enum name does
137-
* not break the published API of env var names.
138-
* </p>
139-
*/
140-
private final String literal;
141-
142-
EnvVars(final String literal) {
143-
this.literal = literal;
144-
}
143+
private final String literal;
144+
145+
EnvVars(final String literal) {
146+
this.literal = literal;
145147
}
148+
}
146149
}

src/main/java/io/securecodebox/persistence/defectdojo/exception/ConfigException.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
* Indicates a missing {@link io.securecodebox.persistence.defectdojo.config.Config config property}
1010
*/
1111
public final class ConfigException extends RuntimeException {
12-
public ConfigException(final String message) {
13-
super(message);
14-
}
15-
public ConfigException(final String message, final Throwable cause) {
16-
super(message, cause);
17-
}
12+
public ConfigException(final String message) {
13+
super(message);
14+
}
15+
16+
public ConfigException(final String message, final Throwable cause) {
17+
super(message, cause);
18+
}
1819
}

src/main/java/io/securecodebox/persistence/defectdojo/exception/PersistenceException.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
package io.securecodebox.persistence.defectdojo.exception;
66

77
public final class PersistenceException extends RuntimeException {
8-
public PersistenceException(String message) {
9-
super(message);
10-
}
8+
public PersistenceException(String message) {
9+
super(message);
10+
}
1111

12-
public PersistenceException(String message, Throwable cause) {
13-
super(message, cause);
14-
}
12+
public PersistenceException(String message, Throwable cause) {
13+
super(message, cause);
14+
}
1515
}

0 commit comments

Comments
 (0)