Skip to content

Commit 629092b

Browse files
committed
palantir java format
1 parent 8b4cb6f commit 629092b

File tree

97 files changed

+1137
-1543
lines changed

Some content is hidden

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

97 files changed

+1137
-1543
lines changed

.github/workflows/spotless.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Spotless Check
22
on: [push, workflow_dispatch]
33

44
concurrency:
5-
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}"
65
cancel-in-progress: true
76
jobs:
87
check:
@@ -19,4 +18,4 @@ jobs:
1918
java-version: 21
2019
distribution: 'zulu'
2120
- name: Run Spotless Check
22-
run: mvn --batch-mode --no-transfer-progress spotless:check ${{ inputs.maven-args }}
21+
run: mvn --batch-mode --no-transfer-progress spotless:check

avaje-jex-freemarker/src/main/java/io/avaje/jex/render/freemarker/FreeMarkerRender.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package io.avaje.jex.render.freemarker;
22

3-
import java.io.IOException;
4-
import java.io.StringWriter;
5-
import java.io.UncheckedIOException;
6-
import java.util.Map;
7-
83
import freemarker.template.Configuration;
94
import freemarker.template.Template;
105
import freemarker.template.TemplateException;
116
import freemarker.template.Version;
127
import io.avaje.jex.http.Context;
138
import io.avaje.jex.spi.TemplateRender;
149
import io.avaje.spi.ServiceProvider;
10+
import java.io.IOException;
11+
import java.io.StringWriter;
12+
import java.io.UncheckedIOException;
13+
import java.util.Map;
1514

1615
@ServiceProvider
1716
public class FreeMarkerRender implements TemplateRender {

avaje-jex-freemarker/src/test/java/io/avaje/jex/render/freemarker/FreeMarkerRenderTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package io.avaje.jex.render.freemarker;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
35
import io.avaje.jex.Jex;
46
import io.avaje.jex.Routing;
57
import io.avaje.jex.test.TestPair;
6-
import org.junit.jupiter.api.AfterAll;
7-
import org.junit.jupiter.api.Test;
8-
98
import java.net.http.HttpResponse;
109
import java.util.List;
1110
import java.util.Map;
12-
13-
import static org.assertj.core.api.Assertions.assertThat;
11+
import org.junit.jupiter.api.AfterAll;
12+
import org.junit.jupiter.api.Test;
1413

1514
class FreeMarkerRenderTest {
1615

avaje-jex-freemarker/src/test/java/io/avaje/jex/render/freemarker/FreeMarkerServiceLoaderTest.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
package io.avaje.jex.render.freemarker;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
35
import io.avaje.jex.Jex;
46
import io.avaje.jex.test.TestPair;
5-
import org.junit.jupiter.api.AfterAll;
6-
import org.junit.jupiter.api.Test;
7-
87
import java.net.http.HttpResponse;
98
import java.util.Map;
10-
11-
import static org.assertj.core.api.Assertions.assertThat;
9+
import org.junit.jupiter.api.AfterAll;
10+
import org.junit.jupiter.api.Test;
1211

1312
class FreeMarkerServiceLoaderTest {
1413

1514
static TestPair pair = init();
1615

1716
static TestPair init() {
18-
var app =
19-
Jex.create()
20-
.routing(
21-
routing ->
22-
routing
23-
.get("/noModel", ctx -> ctx.render("one.ftl"))
24-
.get(
25-
"/withModel",
26-
ctx -> ctx.render("two.ftl", Map.of("message", "hello"))));
17+
var app = Jex.create().routing(routing -> routing.get("/noModel", ctx -> ctx.render("one.ftl"))
18+
.get("/withModel", ctx -> ctx.render("two.ftl", Map.of("message", "hello"))));
2719
// not explicitly registered so auto registered via service loader
2820
return TestPair.create(app);
2921
}

avaje-jex-htmx/src/main/java/io/avaje/jex/htmx/HxHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/**
66
* Wrap a Handler with filtering for Htmx specific headers.
77
*
8-
* <p>The underlying Handler will not be invoked unless the request is a Htmx request and matches
9-
* the required attributes.
8+
* <p>The underlying Handler will not be invoked unless the request is a Htmx request and matches the required
9+
* attributes.
1010
*/
1111
public interface HxHandler {
1212

avaje-jex-mustache/src/main/java/io/avaje/jex/render/mustache/MustacheRender.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import com.github.mustachejava.DefaultMustacheFactory;
44
import com.github.mustachejava.MustacheFactory;
5-
65
import io.avaje.jex.http.Context;
76
import io.avaje.jex.spi.TemplateRender;
87
import io.avaje.spi.ServiceProvider;
9-
108
import java.io.IOException;
119
import java.io.StringWriter;
1210
import java.io.UncheckedIOException;

avaje-jex-mustache/src/test/java/io/avaje/jex/render/mustache/MustacheRenderTest.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
package io.avaje.jex.render.mustache;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
35
import io.avaje.jex.Jex;
46
import io.avaje.jex.test.TestPair;
5-
import org.junit.jupiter.api.AfterAll;
6-
import org.junit.jupiter.api.Test;
7-
87
import java.net.http.HttpResponse;
98
import java.util.Map;
10-
11-
import static org.assertj.core.api.Assertions.assertThat;
9+
import org.junit.jupiter.api.AfterAll;
10+
import org.junit.jupiter.api.Test;
1211

1312
class MustacheRenderTest {
1413

1514
static TestPair pair0 = init(true);
1615
static TestPair pair1 = init(false);
1716

1817
static TestPair init(boolean explicit) {
19-
var app =
20-
Jex.create()
21-
.routing(
22-
routing ->
23-
routing
24-
.get("/noModel", ctx -> ctx.render("one.mustache"))
25-
.get(
26-
"/withModel",
27-
ctx -> ctx.render("two.mustache", Map.of("message", "hello"))));
18+
var app = Jex.create().routing(routing -> routing.get("/noModel", ctx -> ctx.render("one.mustache"))
19+
.get("/withModel", ctx -> ctx.render("two.mustache", Map.of("message", "hello"))));
2820
if (explicit) {
2921
app.register(new MustacheRender(), "mustache");
3022
}

avaje-jex-static-content/src/main/java/io/avaje/jex/staticcontent/AbstractStaticHandler.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package io.avaje.jex.staticcontent;
22

3+
import com.sun.net.httpserver.HttpExchange;
4+
import io.avaje.jex.compression.CompressedOutputStream;
5+
import io.avaje.jex.compression.CompressionConfig;
6+
import io.avaje.jex.http.BadRequestException;
7+
import io.avaje.jex.http.Context;
8+
import io.avaje.jex.http.ExchangeHandler;
9+
import io.avaje.jex.http.NotFoundException;
310
import java.io.ByteArrayOutputStream;
411
import java.io.IOException;
512
import java.io.InputStream;
@@ -10,15 +17,6 @@
1017
import java.util.concurrent.ConcurrentHashMap;
1118
import java.util.function.Predicate;
1219

13-
import com.sun.net.httpserver.HttpExchange;
14-
15-
import io.avaje.jex.compression.CompressedOutputStream;
16-
import io.avaje.jex.compression.CompressionConfig;
17-
import io.avaje.jex.http.BadRequestException;
18-
import io.avaje.jex.http.Context;
19-
import io.avaje.jex.http.ExchangeHandler;
20-
import io.avaje.jex.http.NotFoundException;
21-
2220
abstract sealed class AbstractStaticHandler implements ExchangeHandler
2321
permits StaticFileHandler, StaticClassResourceHandler {
2422

@@ -72,12 +70,10 @@ protected String getExt(String path) {
7270

7371
protected String lookupMime(String path) {
7472
var lower = path.toLowerCase();
75-
return Objects.requireNonNullElseGet(
76-
MIME_MAP.getContentTypeFor(path),
77-
() -> {
78-
String ext = getExt(lower);
79-
return mimeTypes.getOrDefault(ext, "application/octet-stream");
80-
});
73+
return Objects.requireNonNullElseGet(MIME_MAP.getContentTypeFor(path), () -> {
74+
String ext = getExt(lower);
75+
return mimeTypes.getOrDefault(ext, "application/octet-stream");
76+
});
8177
}
8278

8379
protected boolean isCached(final String path) {

avaje-jex-static-content/src/main/java/io/avaje/jex/staticcontent/ClassResourceLoader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
/**
66
* Loading resources from the classpath or module path.
77
*
8-
* <p>When not specified Avaje Jex provides a default implementation that looks to find resources
9-
* using the class loader associated with the ClassResourceLoader.
8+
* <p>When not specified Avaje Jex provides a default implementation that looks to find resources using the class loader
9+
* associated with the ClassResourceLoader.
1010
*
11-
* <p>As a fallback, {@link ClassLoader#getSystemResourceAsStream(String)} is used if the loader
12-
* returns null.
11+
* <p>As a fallback, {@link ClassLoader#getSystemResourceAsStream(String)} is used if the loader returns null.
1312
*/
1413
public interface ClassResourceLoader {
1514

avaje-jex-static-content/src/main/java/io/avaje/jex/staticcontent/DefaultResourceLoader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ public URL loadResource(String resourcePath) {
2121
var url = clazz.getResource(resourcePath);
2222
if (url == null) {
2323
// search the module path for top level resource
24-
url =
25-
Optional.ofNullable(ClassLoader.getSystemResource(resourcePath))
26-
.orElseGet(
27-
() -> Thread.currentThread().getContextClassLoader().getResource(resourcePath));
24+
url = Optional.ofNullable(ClassLoader.getSystemResource(resourcePath))
25+
.orElseGet(
26+
() -> Thread.currentThread().getContextClassLoader().getResource(resourcePath));
2827
}
2928
return Objects.requireNonNull(url, "Unable to locate resource: " + resourcePath);
3029
}

avaje-jex-static-content/src/main/java/io/avaje/jex/staticcontent/StaticClassResourceHandler.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package io.avaje.jex.staticcontent;
22

3+
import io.avaje.jex.compression.CompressionConfig;
4+
import io.avaje.jex.http.Context;
35
import java.net.URL;
46
import java.nio.file.Paths;
57
import java.util.Map;
68
import java.util.function.Predicate;
79

8-
import io.avaje.jex.compression.CompressionConfig;
9-
import io.avaje.jex.http.Context;
10-
1110
final class StaticClassResourceHandler extends AbstractStaticHandler {
1211

1312
private final URL indexFile;
@@ -25,14 +24,7 @@ final class StaticClassResourceHandler extends AbstractStaticHandler {
2524
URL singleFile,
2625
boolean precompress,
2726
CompressionConfig compressionConfig) {
28-
super(
29-
urlPrefix,
30-
filesystemRoot,
31-
mimeTypes,
32-
headers,
33-
skipFilePredicate,
34-
precompress,
35-
compressionConfig);
27+
super(urlPrefix, filesystemRoot, mimeTypes, headers, skipFilePredicate, precompress, compressionConfig);
3628

3729
this.resourceLoader = resourceLoader;
3830
this.indexFile = indexFile;

avaje-jex-static-content/src/main/java/io/avaje/jex/staticcontent/StaticContent.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.avaje.jex.staticcontent;
22

3-
import java.net.URLConnection;
4-
import java.util.function.Predicate;
5-
63
import io.avaje.jex.http.Context;
74
import io.avaje.jex.security.Role;
85
import io.avaje.jex.spi.JexPlugin;
6+
import java.net.URLConnection;
7+
import java.util.function.Predicate;
98

109
/**
1110
* Static content resource handler.
@@ -34,10 +33,7 @@ static Builder createCP(String resourceRoot) {
3433
return StaticResourceHandlerBuilder.builder(resourceRoot);
3534
}
3635

37-
/**
38-
* Create and return a new static content class path configuration with the `/public` directory as
39-
* the root.
40-
*/
36+
/** Create and return a new static content class path configuration with the `/public` directory as the root. */
4137
static Builder createCP() {
4238
return StaticResourceHandlerBuilder.builder("/public/");
4339
}
@@ -79,8 +75,8 @@ sealed interface Builder permits StaticResourceHandlerBuilder {
7975
Builder preCompress();
8076

8177
/**
82-
* Sets a custom resource loader for loading class/module path resources. This is normally used
83-
* when running the application on the module path when files cannot be discovered.
78+
* Sets a custom resource loader for loading class/module path resources. This is normally used when running the
79+
* application on the module path when files cannot be discovered.
8480
*
8581
* <p>Example usage: {@code service.resourceLoader(ClassResourceLoader.create(getClass())) }
8682
*
@@ -90,12 +86,10 @@ sealed interface Builder permits StaticResourceHandlerBuilder {
9086
Builder resourceLoader(ClassResourceLoader resourceLoader);
9187

9288
/**
93-
* Adds a new MIME type mapping to the configuration. (Default: uses {@link
94-
* URLConnection#getFileNameMap()}
89+
* Adds a new MIME type mapping to the configuration. (Default: uses {@link URLConnection#getFileNameMap()}
9590
*
9691
* @param ext the file extension (e.g., "html", "css", "js")
97-
* @param mimeType the corresponding MIME type (e.g., "text/html", "text/css",
98-
* "application/javascript")
92+
* @param mimeType the corresponding MIME type (e.g., "text/html", "text/css", "application/javascript")
9993
* @return the updated configuration
10094
*/
10195
Builder putMimeTypeMapping(String ext, String mimeType);

avaje-jex-static-content/src/main/java/io/avaje/jex/staticcontent/StaticFileHandler.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
package io.avaje.jex.staticcontent;
22

3+
import com.sun.net.httpserver.HttpExchange;
4+
import io.avaje.jex.compression.CompressionConfig;
5+
import io.avaje.jex.http.Context;
36
import java.io.File;
47
import java.io.FileInputStream;
58
import java.io.FileNotFoundException;
69
import java.io.IOException;
710
import java.util.Map;
811
import java.util.function.Predicate;
912

10-
import com.sun.net.httpserver.HttpExchange;
11-
12-
import io.avaje.jex.compression.CompressionConfig;
13-
import io.avaje.jex.http.Context;
14-
1513
final class StaticFileHandler extends AbstractStaticHandler {
1614

1715
private final File indexFile;
@@ -27,14 +25,7 @@ final class StaticFileHandler extends AbstractStaticHandler {
2725
File singleFile,
2826
boolean precompress,
2927
CompressionConfig compressionConfig) {
30-
super(
31-
urlPrefix,
32-
filesystemRoot,
33-
mimeTypes,
34-
headers,
35-
skipFilePredicate,
36-
precompress,
37-
compressionConfig);
28+
super(urlPrefix, filesystemRoot, mimeTypes, headers, skipFilePredicate, precompress, compressionConfig);
3829
this.indexFile = welcomeFile;
3930
this.singleFile = singleFile;
4031
}

0 commit comments

Comments
 (0)