Skip to content

Commit c879113

Browse files
committed
format
1 parent cd2607d commit c879113

File tree

72 files changed

+1093
-806
lines changed

Some content is hidden

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

72 files changed

+1093
-806
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ class FreeMarkerServiceLoaderTest {
1414
static TestPair pair = init();
1515

1616
static TestPair init() {
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"))));
17+
var app =
18+
Jex.create()
19+
.routing(
20+
routing ->
21+
routing
22+
.get("/noModel", ctx -> ctx.render("one.ftl"))
23+
.get(
24+
"/withModel",
25+
ctx -> ctx.render("two.ftl", Map.of("message", "hello"))));
1926
// not explicitly registered so auto registered via service loader
2027
return TestPair.create(app);
2128
}

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 the required
9-
* attributes.
8+
* <p>The underlying Handler will not be invoked unless the request is a Htmx request and matches
9+
* the required attributes.
1010
*/
1111
public interface HxHandler {
1212

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ class MustacheRenderTest {
1515
static TestPair pair1 = init(false);
1616

1717
static TestPair init(boolean explicit) {
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"))));
18+
var app =
19+
Jex.create()
20+
.routing(
21+
routing ->
22+
routing
23+
.get("/noModel", ctx -> ctx.render("one.mustache"))
24+
.get(
25+
"/withModel",
26+
ctx -> ctx.render("two.mustache", Map.of("message", "hello"))));
2027
if (explicit) {
2128
app.register(new MustacheRender(), "mustache");
2229
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ protected String getExt(String path) {
7070

7171
protected String lookupMime(String path) {
7272
var lower = path.toLowerCase();
73-
return Objects.requireNonNullElseGet(MIME_MAP.getContentTypeFor(path), () -> {
74-
String ext = getExt(lower);
75-
return mimeTypes.getOrDefault(ext, "application/octet-stream");
76-
});
73+
return Objects.requireNonNullElseGet(
74+
MIME_MAP.getContentTypeFor(path),
75+
() -> {
76+
String ext = getExt(lower);
77+
return mimeTypes.getOrDefault(ext, "application/octet-stream");
78+
});
7779
}
7880

7981
protected boolean isCached(final String path) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
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 using the class loader
9-
* associated with the ClassResourceLoader.
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.
1010
*
11-
* <p>As a fallback, {@link ClassLoader#getSystemResourceAsStream(String)} is used if the loader returns null.
11+
* <p>As a fallback, {@link ClassLoader#getSystemResourceAsStream(String)} is used if the loader
12+
* returns null.
1213
*/
1314
public interface ClassResourceLoader {
1415

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ 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 = Optional.ofNullable(ClassLoader.getSystemResource(resourcePath))
25-
.orElseGet(
26-
() -> Thread.currentThread().getContextClassLoader().getResource(resourcePath));
24+
url =
25+
Optional.ofNullable(ClassLoader.getSystemResource(resourcePath))
26+
.orElseGet(
27+
() -> Thread.currentThread().getContextClassLoader().getResource(resourcePath));
2728
}
2829
return Objects.requireNonNull(url, "Unable to locate resource: " + resourcePath);
2930
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ final class StaticClassResourceHandler extends AbstractStaticHandler {
2424
URL singleFile,
2525
boolean precompress,
2626
CompressionConfig compressionConfig) {
27-
super(urlPrefix, filesystemRoot, mimeTypes, headers, skipFilePredicate, precompress, compressionConfig);
27+
super(
28+
urlPrefix,
29+
filesystemRoot,
30+
mimeTypes,
31+
headers,
32+
skipFilePredicate,
33+
precompress,
34+
compressionConfig);
2835

2936
this.resourceLoader = resourceLoader;
3037
this.indexFile = indexFile;

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

Lines changed: 2 additions & 3 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.

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ final class StaticFileHandler extends AbstractStaticHandler {
2525
File singleFile,
2626
boolean precompress,
2727
CompressionConfig compressionConfig) {
28-
super(urlPrefix, filesystemRoot, mimeTypes, headers, skipFilePredicate, precompress, compressionConfig);
28+
super(
29+
urlPrefix,
30+
filesystemRoot,
31+
mimeTypes,
32+
headers,
33+
skipFilePredicate,
34+
precompress,
35+
compressionConfig);
2936
this.indexFile = welcomeFile;
3037
this.singleFile = singleFile;
3138
}

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
final class StaticResourceHandlerBuilder implements StaticContent.Builder, StaticContent {
1616

1717
private static final String FAILED_TO_LOCATE_FILE = "Failed to locate file: ";
18-
private static final String DIRECTORY_INDEX_FAILURE = "Failed to locate Directory Index Resource: ";
18+
private static final String DIRECTORY_INDEX_FAILURE =
19+
"Failed to locate Directory Index Resource: ";
1920
private static final Predicate<Context> NO_OP_PREDICATE = ctx -> false;
2021
private static final ClassResourceLoader DEFAULT_LOADER = new DefaultResourceLoader();
2122

@@ -49,17 +50,20 @@ public StaticContent build() {
4950
}
5051

5152
ExchangeHandler createHandler(CompressionConfig compress) {
52-
path = Objects.requireNonNull(path)
53-
.transform(this::prependSlash)
54-
.transform(s -> s.endsWith("/*") ? s.substring(0, s.length() - 2) : s);
53+
path =
54+
Objects.requireNonNull(path)
55+
.transform(this::prependSlash)
56+
.transform(s -> s.endsWith("/*") ? s.substring(0, s.length() - 2) : s);
5557

5658
root = isClasspath ? root.transform(this::prependSlash) : root;
5759
if (isClasspath && "/".equals(root)) {
58-
throw new IllegalArgumentException("Cannot serve full classpath, please configure a classpath prefix");
60+
throw new IllegalArgumentException(
61+
"Cannot serve full classpath, please configure a classpath prefix");
5962
}
6063

6164
if (root.endsWith("/") && directoryIndex == null) {
62-
throw new IllegalArgumentException("Directory Index file is required when serving directories");
65+
throw new IllegalArgumentException(
66+
"Directory Index file is required when serving directories");
6367
}
6468

6569
if (!isClasspath) {
@@ -147,7 +151,15 @@ private StaticFileHandler fileLoader(CompressionConfig compress) {
147151
}
148152

149153
return new StaticFileHandler(
150-
path, fsRoot, mimeTypes, headers, skipFilePredicate, dirIndex, singleFile, precompress, compress);
154+
path,
155+
fsRoot,
156+
mimeTypes,
157+
headers,
158+
skipFilePredicate,
159+
dirIndex,
160+
singleFile,
161+
precompress,
162+
compress);
151163
}
152164

153165
private StaticClassResourceHandler classPathHandler(CompressionConfig compress) {

0 commit comments

Comments
 (0)