Skip to content

Commit 5128904

Browse files
committed
eclipse test
1 parent b8ad08e commit 5128904

File tree

12 files changed

+70
-55
lines changed

12 files changed

+70
-55
lines changed

src/main/java/com/mindee/AsyncPollingOptions.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ public class AsyncPollingOptions {
2222
Integer maxRetries;
2323

2424
@Builder
25-
private AsyncPollingOptions(
26-
Double initialDelaySec,
27-
Double intervalSec,
28-
Integer maxRetries
29-
) {
25+
private AsyncPollingOptions(Double initialDelaySec, Double intervalSec, Integer maxRetries) {
3026
this.initialDelaySec = initialDelaySec == null ? 2.0 : initialDelaySec;
3127
this.intervalSec = intervalSec == null ? 1.5 : intervalSec;
3228
this.maxRetries = maxRetries == null ? 80 : maxRetries;

src/main/java/com/mindee/InferenceParameters.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ public final class InferenceParameters {
3636
*/
3737
private final String alias;
3838
/**
39-
* Webhook IDs to call after all processing is finished. If empty, no webhooks will be used.
39+
* Webhook IDs to call after all processing is finished.
40+
* If empty, no webhooks will be used.
4041
*/
4142
private final String[] webhookIds;
4243
/**
4344
* Polling options. Set only if having timeout issues.
4445
*/
4546
private final AsyncPollingOptions pollingOptions;
4647
/**
47-
* Additional text context used by the model during inference. Not recommended, for specific use only.
48+
* Additional text context used by the model during inference.
49+
* Not recommended, for specific use only.
4850
*/
4951
private final String textContext;
5052
/**
@@ -73,7 +75,7 @@ public static final class Builder {
7375
private Boolean polygon = null;
7476
private Boolean confidence = null;
7577
private String alias;
76-
private String[] webhookIds = new String[]{};
78+
private String[] webhookIds = new String[] {};
7779
private String textContext;
7880
private String dataSchema;
7981
private AsyncPollingOptions pollingOptions = AsyncPollingOptions.builder().build();

src/main/java/com/mindee/input/InputSourceUtils.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ public static String[] splitNameStrict(String filename) throws MindeeException {
6464
} else {
6565
throw new MindeeException("File name must include a valid extension.");
6666
}
67-
return new String[] {name, extension};
67+
return new String[] { name, extension };
6868
}
6969

7070
/**
7171
* Returns true if the file is a PDF.
7272
*/
7373
public static boolean isPdf(byte[] fileBytes) {
74-
try (PDDocument document = Loader.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(fileBytes)))) {
74+
try (
75+
PDDocument document = Loader
76+
.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(fileBytes)))
77+
) {
7578
return true;
7679
} catch (IOException e) {
7780
return false;
@@ -96,7 +99,9 @@ public static void validateUrl(URL inputUrl) {
9699
*/
97100
public static boolean hasSourceText(byte[] fileBytes) {
98101
try {
99-
PDDocument document = Loader.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(fileBytes)));
102+
PDDocument document = Loader.loadPDF(
103+
new RandomAccessReadBuffer(new ByteArrayInputStream(fileBytes))
104+
);
100105
PDFTextStripper stripper = new PDFTextStripper();
101106

102107
for (int i = 0; i < document.getNumberOfPages(); i++) {

src/main/java/com/mindee/input/LocalInputSource.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public LocalInputSource(String fileAsBase64, String filename) {
5757

5858
/**
5959
* Get the number of pages in the document.
60+
*
6061
* @return the number of pages in the current file.
6162
* @throws IOException If an I/O error occurs during the PDF operation.
6263
*/
@@ -76,9 +77,7 @@ public int getPageCount() throws IOException {
7677
public void applyPageOptions(PageOptions pageOptions) throws IOException {
7778
if (pageOptions != null && this.isPdf()) {
7879
PdfOperation pdfOperation = new PdfBoxApi();
79-
this.file = pdfOperation.split(
80-
new SplitQuery(this.file, pageOptions)
81-
).getFile();
80+
this.file = pdfOperation.split(new SplitQuery(this.file, pageOptions)).getFile();
8281
}
8382
}
8483

@@ -91,8 +90,11 @@ public boolean hasSourceText() {
9190
}
9291

9392
public void compress(
94-
Integer quality, Integer maxWidth, Integer maxHeight,
95-
Boolean forceSourceText, Boolean disableSourceText
93+
Integer quality,
94+
Integer maxWidth,
95+
Integer maxHeight,
96+
Boolean forceSourceText,
97+
Boolean disableSourceText
9698
) throws IOException {
9799
if (isPdf()) {
98100
this.file = PdfCompressor.compressPdf(this.file, quality, forceSourceText, disableSourceText);
@@ -102,7 +104,9 @@ public void compress(
102104
}
103105

104106
public void compress(
105-
Integer quality, Integer maxWidth, Integer maxHeight,
107+
Integer quality,
108+
Integer maxWidth,
109+
Integer maxHeight,
106110
Boolean forceSourceText
107111
) throws IOException {
108112
this.compress(quality, maxWidth, maxHeight, forceSourceText, true);

src/main/java/com/mindee/input/LocalResponse.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public class LocalResponse {
2929

3030
/**
3131
* Load from an {@link InputStream}.
32+
*
3233
* @param input will be decoded as UTF-8.
3334
*/
3435
public LocalResponse(InputStream input) {
35-
this.file = this.getBytes(
36-
new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))
37-
.lines()
38-
);
36+
this.file = this
37+
.getBytes(new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines());
3938
}
4039

4140
/**
4241
* Load from a {@link String}.
42+
*
4343
* @param input will be decoded as UTF-8.
4444
*/
4545
public LocalResponse(String input) {
@@ -48,22 +48,20 @@ public LocalResponse(String input) {
4848

4949
/**
5050
* Load from a {@link File}.
51+
*
5152
* @param input will be decoded as UTF-8.
5253
*/
5354
public LocalResponse(File input) throws IOException {
54-
this.file = this.getBytes(
55-
Files.lines(input.toPath(), StandardCharsets.UTF_8)
56-
);
55+
this.file = this.getBytes(Files.lines(input.toPath(), StandardCharsets.UTF_8));
5756
}
5857

5958
/**
6059
* Load from a {@link Path}.
60+
*
6161
* @param input will be decoded as UTF-8.
6262
*/
6363
public LocalResponse(Path input) throws IOException {
64-
this.file = this.getBytes(
65-
Files.lines(input, StandardCharsets.UTF_8)
66-
);
64+
this.file = this.getBytes(Files.lines(input, StandardCharsets.UTF_8));
6765
}
6866

6967
private byte[] getBytes(Stream<String> stream) {
@@ -72,6 +70,7 @@ private byte[] getBytes(Stream<String> stream) {
7270

7371
/**
7472
* Get the HMAC signature of the payload.
73+
*
7574
* @param secretKey Your secret key from the Mindee platform.
7675
* @return The generated HMAC signature.
7776
*/
@@ -98,6 +97,7 @@ public String getHmacSignature(String secretKey) {
9897

9998
/**
10099
* Verify that the payload's signature matches the one received from the server.
100+
*
101101
* @param secretKey Your secret key from the Mindee platform.
102102
* @param signature The signature from the "X-Mindee-Hmac-Signature" HTTP header.
103103
* @return true if the signatures match.
@@ -106,13 +106,12 @@ public boolean isValidHmacSignature(String secretKey, String signature) {
106106
return signature.equals(getHmacSignature(secretKey));
107107
}
108108

109-
110109
/**
111110
* Deserialize this local JSON payload into a specific {@link CommonResponse}
112111
* subtype: {@code InferenceResponse}, {@code JobResponse}.
113112
*
114113
* @param responseClass the concrete class to instantiate
115-
* @param <T> generic {@link CommonResponse}
114+
* @param <T> generic {@link CommonResponse}
116115
* @return Either a {@code InferenceResponse} or {@code JobResponse} instance.
117116
* @throws MindeeException if the payload cannot be deserialized into the requested type
118117
*/

src/main/java/com/mindee/input/PageOptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class PageOptions {
2929

3030
/**
3131
* Default constructor.
32+
*
3233
* @deprecated Use the Builder pattern instead.
3334
*/
3435
@Deprecated
@@ -38,13 +39,11 @@ public PageOptions(List<Integer> pages) {
3839

3940
/**
4041
* Constructor with operation.
42+
*
4143
* @deprecated Use the Builder pattern instead.
4244
*/
4345
@Deprecated
44-
public PageOptions(
45-
List<Integer> pages,
46-
PageOptionsOperation operation
47-
) {
46+
public PageOptions(List<Integer> pages, PageOptionsOperation operation) {
4847
this(pages, operation, 0);
4948
}
5049

@@ -80,6 +79,7 @@ public Builder operation(PageOptionsOperation operation) {
8079
this.operation = operation;
8180
return this;
8281
}
82+
8383
public Builder onMinPages(Integer onMinPages) {
8484
this.onMinPages = onMinPages;
8585
return this;

src/main/java/com/mindee/input/URLInputSource.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class URLInputSource {
3939

4040
/**
4141
* Creates a new builder for an URLInputSource.
42+
*
4243
* @param url URL to fetch the file from.
4344
* @return An instance of {@link URLInputSource}.
4445
*/
@@ -76,8 +77,9 @@ protected HttpURLConnection createConnection(String urlString) throws IOExceptio
7677
connection.setInstanceFollowRedirects(true);
7778

7879
if (username != null && password != null) {
79-
String encodedCredentials =
80-
Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
80+
String encodedCredentials = Base64
81+
.getEncoder()
82+
.encodeToString((username + ":" + password).getBytes());
8183
connection.setRequestProperty("Authorization", "Basic " + encodedCredentials);
8284
}
8385
if (token != null) {
@@ -99,7 +101,7 @@ private HttpURLConnection handleRedirects(HttpURLConnection connection) throws I
99101
connection.disconnect();
100102

101103
HttpURLConnection newConnection = createConnection(newUrl);
102-
return handleRedirects(newConnection); // Recursive call to handle multiple redirects
104+
return handleRedirects(newConnection); // Recursive call to handle multiple redirects
103105
}
104106
return connection;
105107
}
@@ -110,8 +112,10 @@ private void saveTempFile(InputStream in) throws IOException {
110112
Path tempFile = Files.createTempFile(prefix, ".tmp");
111113
localFilename = tempFile.toString();
112114

113-
try (InputStream inputStream = in;
114-
OutputStream outputStream = Files.newOutputStream(tempFile)) {
115+
try (
116+
InputStream inputStream = in;
117+
OutputStream outputStream = Files.newOutputStream(tempFile)
118+
) {
115119
byte[] buffer = new byte[4096];
116120
int bytesRead;
117121
while ((bytesRead = inputStream.read(buffer)) != -1) {
@@ -120,7 +124,6 @@ private void saveTempFile(InputStream in) throws IOException {
120124
}
121125
}
122126

123-
124127
private void saveFile(InputStream in, String filepath) throws IOException {
125128
File outputFile = new File(filepath);
126129

@@ -235,7 +238,6 @@ public Builder withLocalFilename(String filename) {
235238
return this;
236239
}
237240

238-
239241
/**
240242
* Build the {@link URLInputSource} object.
241243
*

src/main/java/com/mindee/parsing/v2/field/DynamicField.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public ObjectField getObjectField() throws IllegalStateException {
7676
*
7777
* @param type the class representing the desired field type
7878
* @param <T> the type of field to return
79-
* @throws IllegalArgumentException if the requested type is not SimpleField, ListField, or ObjectField
79+
* @throws IllegalArgumentException if the requested type is not:
80+
* SimpleField, ListField, or ObjectField
8081
* @throws IllegalStateException if the field's internal type does not match the requested type
8182
*/
8283
public <T extends BaseField> T getField(Class<T> type) throws IllegalArgumentException {
@@ -89,21 +90,26 @@ public <T extends BaseField> T getField(Class<T> type) throws IllegalArgumentExc
8990
if (type == ObjectField.class) {
9091
return (T) this.getObjectField();
9192
}
92-
throw new IllegalArgumentException(
93-
"Cannot cast to " + type.getSimpleName()
94-
);
93+
throw new IllegalArgumentException("Cannot cast to " + type.getSimpleName());
9594
}
9695

9796
@Override
9897
public String toString() {
99-
if (simpleField != null) return simpleField.toString();
100-
if (listField != null) return listField.toString();
101-
if (objectField != null) return objectField.toString();
98+
if (simpleField != null)
99+
return simpleField.toString();
100+
if (listField != null)
101+
return listField.toString();
102+
if (objectField != null)
103+
return objectField.toString();
102104
return "";
103105
}
104106

105107
/**
106108
* Possible field kinds.
107109
*/
108-
public enum FieldType { SIMPLE_FIELD, OBJECT_FIELD, LIST_FIELD }
110+
public enum FieldType {
111+
SIMPLE_FIELD,
112+
OBJECT_FIELD,
113+
LIST_FIELD,
114+
}
109115
}

src/main/java/com/mindee/parsing/v2/field/ListField.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public final class ListField extends BaseField {
3030
* Retrieves the {@code items} as {@code SimpleField} objects.
3131
*
3232
* @return a list of {@code SimpleField} objects
33-
* @throws IllegalStateException if any dynamic field in the list is not of type {@code SIMPLE_FIELD}
33+
* @throws IllegalStateException if any dynamic field in the list is not of type
34+
* {@code SIMPLE_FIELD}
3435
*/
3536
public List<SimpleField> getSimpleItems() throws IllegalStateException {
3637
List<SimpleField> simpleItems = new ArrayList<>();
@@ -46,7 +47,8 @@ public List<SimpleField> getSimpleItems() throws IllegalStateException {
4647
* Retrieves the {@code items} as {@code ObjectField} objects.
4748
*
4849
* @return a list of {@code ObjectField} objects
49-
* @throws IllegalStateException if any dynamic field in the list is not of type {@code OBJECT_FIELD}
50+
* @throws IllegalStateException if any dynamic field in the list is not of type
51+
* {@code OBJECT_FIELD}
5052
*/
5153
public List<ObjectField> getObjectItems() throws IllegalStateException {
5254
List<ObjectField> objectItems = new ArrayList<>();

src/main/java/com/mindee/parsing/v2/field/ObjectField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ObjectField extends BaseField {
2929
* {@code SimpleField} objects, keyed by their field names.
3030
*
3131
* @return a {@link LinkedHashMap} containing the field names as keys and their corresponding
32-
* {@code SimpleField} instances as values
32+
* {@code SimpleField} instances as values
3333
* @throws IllegalStateException if any field is not of type {@code SIMPLE_FIELD}
3434
*/
3535
public LinkedHashMap<String, SimpleField> getSimpleFields() throws IllegalStateException {

0 commit comments

Comments
 (0)