Skip to content

Commit db2ac43

Browse files
authored
Clean up inspection warnings (#12)
* Clean up warnings * Refactor
1 parent 917a803 commit db2ac43

19 files changed

+120
-121
lines changed

checkstyle.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<!-- Checks for Size Violations. -->
7575
<!-- See http://checkstyle.sf.net/config_sizes.html -->
7676
<module name="FileLength"/>
77+
<module name="LineLength">
78+
<property name="max" value="120"/>
79+
</module>
7780

7881
<!-- Checks for whitespace -->
7982
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
@@ -133,9 +136,6 @@
133136

134137
<!-- Checks for Size Violations. -->
135138
<!-- See http://checkstyle.sf.net/config_sizes.html -->
136-
<module name="LineLength">
137-
<property name="max" value="120"/>
138-
</module>
139139
<module name="MethodLength"/>
140140
<module name="ParameterNumber">
141141
<property name="max" value="8"/>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<plugin>
8585
<groupId>org.apache.maven.plugins</groupId>
8686
<artifactId>maven-enforcer-plugin</artifactId>
87-
<version>3.0.0-M2</version>
87+
<version>3.0.0-M3</version>
8888
<executions>
8989
<execution>
9090
<id>enforce-no-snapshots</id>
@@ -189,7 +189,7 @@
189189
<plugin>
190190
<groupId>org.apache.maven.plugins</groupId>
191191
<artifactId>maven-checkstyle-plugin</artifactId>
192-
<version>3.1.0</version>
192+
<version>3.1.1</version>
193193
<executions>
194194
<execution>
195195
<id>validate</id>

src/main/java/ai/preferred/venom/fetcher/AsyncFetcher.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -144,31 +144,6 @@ public final class AsyncFetcher implements Fetcher {
144144
*/
145145
private final boolean compressed;
146146

147-
/**
148-
* Creates {@link BasicFuture} and fails the request with a specified exception.
149-
*
150-
* @param callback request callback
151-
* @param ex specified exeption
152-
* @return BasicFuture created
153-
*/
154-
private static Future<Response> failRequest(final FutureCallback<Response> callback, final Exception ex) {
155-
final BasicFuture<Response> f = new BasicFuture<>(callback);
156-
f.failed(ex);
157-
return f;
158-
}
159-
160-
/**
161-
* Creates {@link BasicFuture} and cancels the request.
162-
*
163-
* @param callback request callback
164-
* @return BasicFuture created
165-
*/
166-
private static Future<Response> cancelRequest(final FutureCallback<Response> callback) {
167-
final BasicFuture<Response> f = new BasicFuture<>(callback);
168-
f.cancel(true);
169-
return f;
170-
}
171-
172147
/**
173148
* Constructs an instance of AsyncFetcher.
174149
*
@@ -242,6 +217,31 @@ private AsyncFetcher(final Builder builder) {
242217
httpClient = clientBuilder.build();
243218
}
244219

220+
/**
221+
* Creates {@link BasicFuture} and fails the request with a specified exception.
222+
*
223+
* @param callback request callback
224+
* @param ex specified exception
225+
* @return BasicFuture created
226+
*/
227+
private static Future<Response> failRequest(final FutureCallback<Response> callback, final Exception ex) {
228+
final BasicFuture<Response> f = new BasicFuture<>(callback);
229+
f.failed(ex);
230+
return f;
231+
}
232+
233+
/**
234+
* Creates {@link BasicFuture} and cancels the request.
235+
*
236+
* @param callback request callback
237+
* @return BasicFuture created
238+
*/
239+
private static Future<Response> cancelRequest(final FutureCallback<Response> callback) {
240+
final BasicFuture<Response> f = new BasicFuture<>(callback);
241+
f.cancel(true);
242+
return f;
243+
}
244+
245245
/**
246246
* Create an instance of AsyncFetcher with default options.
247247
*
@@ -467,7 +467,7 @@ public static final class Builder {
467467
/**
468468
* The file manager used to store raw responses.
469469
*/
470-
private FileManager fileManager;
470+
private FileManager<?> fileManager;
471471

472472
/**
473473
* A list of headers to append to request.
@@ -623,7 +623,7 @@ public Builder disableCookies() {
623623
* @param fileManager file manager to be used.
624624
* @return this
625625
*/
626-
public Builder setFileManager(final FileManager fileManager) {
626+
public Builder setFileManager(final FileManager<?> fileManager) {
627627
this.fileManager = fileManager;
628628
return this;
629629
}

src/main/java/ai/preferred/venom/fetcher/StorageFetcher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public final class StorageFetcher implements Fetcher {
5656
/**
5757
* The file manager used to store raw responses.
5858
*/
59-
private final FileManager fileManager;
59+
private final FileManager<?> fileManager;
6060

6161
/**
6262
* The validator used.
@@ -85,7 +85,7 @@ private StorageFetcher(final Builder builder) {
8585
* @param fileManager the file manager to use.
8686
* @return A new instance of builder
8787
*/
88-
public static Builder builder(final FileManager fileManager) {
88+
public static Builder builder(final FileManager<?> fileManager) {
8989
return new Builder(fileManager);
9090
}
9191

@@ -136,7 +136,7 @@ public void cancelled() {
136136
});
137137

138138
try {
139-
final Record record = fileManager.get(storageFetcherRequest);
139+
final Record<?> record = fileManager.get(storageFetcherRequest);
140140
if (record == null) {
141141
future.cancel();
142142
LOGGER.info("No content found from storage for: {}", request.getUrl());
@@ -185,7 +185,7 @@ public static final class Builder {
185185
/**
186186
* The file manager used to store raw responses.
187187
*/
188-
private final FileManager fileManager;
188+
private final FileManager<?> fileManager;
189189

190190
/**
191191
* A list of headers to append to request.
@@ -202,7 +202,7 @@ public static final class Builder {
202202
*
203203
* @param fileManager an instance file manager used to store raw responses.
204204
*/
205-
private Builder(final FileManager fileManager) {
205+
private Builder(final FileManager<?> fileManager) {
206206
this.fileManager = fileManager;
207207
headers = Collections.emptyMap();
208208
validator = new PipelineValidator(

src/main/java/ai/preferred/venom/request/VRequest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ private VRequest(final Method method, final String url, final Map<String, String
118118
* @param url Request url
119119
* @return A new instance of builder
120120
*/
121-
public static Builder build(final Method method, final String url) {
122-
return new Builder(method, url);
121+
public static Builder<?> build(final Method method, final String url) {
122+
return new Builder<>(method, url);
123123
}
124124

125125
@Override
@@ -201,8 +201,8 @@ protected Builder(final Method method, final String url) {
201201
* @param url url to fetch.
202202
* @return an instance of builder.
203203
*/
204-
public static Builder get(final String url) {
205-
return new Builder(Method.GET, url);
204+
public static Builder<?> get(final String url) {
205+
return new Builder<>(Method.GET, url);
206206
}
207207

208208
/**
@@ -211,8 +211,8 @@ public static Builder get(final String url) {
211211
* @param url url to fetch.
212212
* @return an instance of builder.
213213
*/
214-
public static Builder post(final String url) {
215-
return new Builder(Method.POST, url);
214+
public static Builder<?> post(final String url) {
215+
return new Builder<>(Method.POST, url);
216216
}
217217

218218
/**
@@ -221,8 +221,8 @@ public static Builder post(final String url) {
221221
* @param url url to fetch.
222222
* @return an instance of builder.
223223
*/
224-
public static Builder head(final String url) {
225-
return new Builder(Method.HEAD, url);
224+
public static Builder<?> head(final String url) {
225+
return new Builder<>(Method.HEAD, url);
226226
}
227227

228228
/**
@@ -231,8 +231,8 @@ public static Builder head(final String url) {
231231
* @param url url to fetch.
232232
* @return an instance of builder.
233233
*/
234-
public static Builder put(final String url) {
235-
return new Builder(Method.PUT, url);
234+
public static Builder<?> put(final String url) {
235+
return new Builder<>(Method.PUT, url);
236236
}
237237

238238
/**
@@ -241,8 +241,8 @@ public static Builder put(final String url) {
241241
* @param url url to fetch.
242242
* @return an instance of builder.
243243
*/
244-
public static Builder delete(final String url) {
245-
return new Builder(Method.DELETE, url);
244+
public static Builder<?> delete(final String url) {
245+
return new Builder<>(Method.DELETE, url);
246246
}
247247

248248
/**
@@ -251,8 +251,8 @@ public static Builder delete(final String url) {
251251
* @param url url to fetch.
252252
* @return an instance of builder.
253253
*/
254-
public static Builder options(final String url) {
255-
return new Builder(Method.OPTIONS, url);
254+
public static Builder<?> options(final String url) {
255+
return new Builder<>(Method.OPTIONS, url);
256256
}
257257

258258
/**

src/main/java/ai/preferred/venom/response/Retrievable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ public interface Retrievable extends Response {
3131
*
3232
* @return record where an archive has been saved
3333
*/
34-
Record getRecord();
34+
Record<?> getRecord();
3535
}

src/main/java/ai/preferred/venom/response/StorageResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class StorageResponse implements Response, Retrievable {
3030
/**
3131
* The record holding this response.
3232
*/
33-
private final Record record;
33+
private final Record<?> record;
3434

3535
/**
3636
* The base url of this response.
@@ -43,7 +43,7 @@ public class StorageResponse implements Response, Retrievable {
4343
* @param record record holding this response
4444
* @param baseUrl base URL of the response
4545
*/
46-
public StorageResponse(final Record record, final String baseUrl) {
46+
public StorageResponse(final Record<?> record, final String baseUrl) {
4747
this.record = record;
4848
this.baseUrl = baseUrl;
4949
}
@@ -79,7 +79,7 @@ public final HttpHost getProxy() {
7979
}
8080

8181
@Override
82-
public final Record getRecord() {
82+
public final Record<?> getRecord() {
8383
return record;
8484
}
8585
}

src/main/java/ai/preferred/venom/storage/DummyFileManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* @author Maksim Tkachenko
3939
* @author Ween Jiann Lee
4040
*/
41-
public class DummyFileManager implements FileManager {
41+
public class DummyFileManager implements FileManager<Object> {
4242

4343
/**
4444
* Logger.
@@ -129,12 +129,12 @@ public final String put(final Request request, final Response response) throws S
129129
}
130130

131131
@Override
132-
public final Record get(final Object i) {
132+
public final Record<Object> get(final Object i) {
133133
throw new UnsupportedOperationException("File not found");
134134
}
135135

136136
@Override
137-
public final Record get(final Request request) {
137+
public final Record<Object> get(final Request request) {
138138
throw new UnsupportedOperationException("File not found");
139139
}
140140

src/main/java/ai/preferred/venom/storage/FileManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public interface FileManager<T> extends AutoCloseable {
6464
* @throws StorageException throws StorageException
6565
*/
6666
@Nullable
67-
Record get(T id) throws StorageException;
67+
Record<T> get(T id) throws StorageException;
6868

6969
/**
7070
* Returns latest record matching request.
@@ -74,6 +74,6 @@ public interface FileManager<T> extends AutoCloseable {
7474
* @throws StorageException throws StorageException
7575
*/
7676
@NotNull
77-
Record get(@NotNull Request request) throws StorageException;
77+
Record<T> get(@NotNull Request request) throws StorageException;
7878

7979
}

src/main/java/ai/preferred/venom/storage/FileManagerCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public class FileManagerCallback implements Callback {
3737
/**
3838
* The file manager used to store raw responses.
3939
*/
40-
private final FileManager fileManager;
40+
private final FileManager<?> fileManager;
4141

4242
/**
4343
* Constructs an instance of file manager callback.
4444
*
4545
* @param fileManager an instance of file manager used to store raw responses
4646
*/
47-
public FileManagerCallback(final FileManager fileManager) {
47+
public FileManagerCallback(final FileManager<?> fileManager) {
4848
this.fileManager = fileManager;
4949
}
5050

0 commit comments

Comments
 (0)