Skip to content

Commit 3ffe3f6

Browse files
committed
javadoc+checkstyle fixes
1 parent dbb324c commit 3ffe3f6

File tree

8 files changed

+74
-8
lines changed

8 files changed

+74
-8
lines changed

jooby/src/main/java/io/jooby/Cors.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.typesafe.config.Config;
99

10+
import javax.annotation.Nonnull;
1011
import java.time.Duration;
1112
import java.util.Arrays;
1213
import java.util.Collections;
@@ -55,7 +56,7 @@ private static class Matcher<T> implements Predicate<T> {
5556

5657
private boolean wild;
5758

58-
public Matcher(final List<String> values, final Predicate<T> predicate) {
59+
Matcher(final List<String> values, final Predicate<T> predicate) {
5960
this.values = values;
6061
this.predicate = predicate;
6162
this.wild = values.contains("*");
@@ -71,6 +72,9 @@ public boolean test(final T value) {
7172
}
7273
}
7374

75+
/** Default max-age in minutes. */
76+
private static final int _30 = 30;
77+
7478
private Matcher<String> origin;
7579

7680
private boolean credentials;
@@ -100,7 +104,7 @@ public Cors() {
100104
setUseCredentials(true);
101105
setMethods("GET", "POST");
102106
setHeaders("X-Requested-With", "Content-Type", "Accept", "Origin");
103-
setMaxAge(Duration.ofMinutes(30));
107+
setMaxAge(Duration.ofMinutes(_30));
104108
}
105109

106110
/**
@@ -112,6 +116,12 @@ public boolean getUseCredentials() {
112116
return this.credentials;
113117
}
114118

119+
/**
120+
* If true, set the <code>Access-Control-Allow-Credentials</code> header.
121+
*
122+
* @param credentials Credentials.
123+
* @return This cors.
124+
*/
115125
public Cors setUseCredentials(boolean credentials) {
116126
this.credentials = credentials;
117127
return this;
@@ -310,7 +320,23 @@ public Cors setMaxAge(final Duration preflightMaxAge) {
310320
return this;
311321
}
312322

313-
public static Cors from(Config conf) {
323+
/**
324+
* Get cors options from application configuration file.
325+
*
326+
* <pre>{@code
327+
* cors {
328+
* origin: *
329+
* methods: [GET, POST]
330+
* headers: [Custom-Header]
331+
* maxAge: 30m
332+
* exposesHeaders: [Header]
333+
* }
334+
* }</pre>
335+
*
336+
* @param conf Configuration.
337+
* @return Cors options.
338+
*/
339+
public static @Nonnull Cors from(@Nonnull Config conf) {
314340
Config cors = conf.hasPath("cors") ? conf.getConfig("cors") : conf;
315341
Cors options = new Cors();
316342
if (cors.hasPath("origin")) {

jooby/src/main/java/io/jooby/CorsHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public CorsHandler(@Nonnull final Cors options) {
5252
this.options = options;
5353
}
5454

55+
/**
56+
* Creates a new {@link CorsHandler} with default options.
57+
*/
5558
public CorsHandler() {
5659
this(new Cors());
5760
}

jooby/src/main/java/io/jooby/Environment.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.List;
2323
import java.util.Map;
2424
import java.util.Optional;
25-
import java.util.StringJoiner;
2625
import java.util.stream.Collectors;
2726
import java.util.stream.Stream;
2827

jooby/src/main/java/io/jooby/Route.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,30 @@ public Route(@Nonnull String method, @Nonnull String pattern, @Nonnull Handler h
648648
return this;
649649
}
650650

651+
/**
652+
* True if route support HTTP OPTIONS.
653+
*
654+
* @return True if route support HTTP OPTIONS.
655+
*/
651656
public boolean isHttpOptions() {
652657
return supportedMethod != null && supportedMethod.contains(Router.OPTIONS);
653658
}
654659

660+
/**
661+
* True if route support HTTP TRACE.
662+
*
663+
* @return True if route support HTTP TRACE.
664+
*/
655665
public boolean isHttpTrace() {
656666
return supportedMethod != null && supportedMethod.contains(Router.TRACE);
657667
}
658668

669+
/**
670+
* Enabled or disabled HTTP Options.
671+
*
672+
* @param enabled Enabled or disabled HTTP Options.
673+
* @return This route.
674+
*/
659675
public @Nonnull Route setHttpOptions(boolean enabled) {
660676
if (supportedMethod == null) {
661677
supportedMethod = new HashSet<>();
@@ -668,6 +684,12 @@ public boolean isHttpTrace() {
668684
return this;
669685
}
670686

687+
/**
688+
* Enabled or disabled HTTP TRACE.
689+
*
690+
* @param enabled Enabled or disabled HTTP TRACE.
691+
* @return This route.
692+
*/
671693
public @Nonnull Route setHttpTrace(boolean enabled) {
672694
if (supportedMethod == null) {
673695
supportedMethod = new HashSet<>();

jooby/src/main/java/io/jooby/Router.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.slf4j.Logger;
99

1010
import javax.annotation.Nonnull;
11-
import javax.annotation.Nullable;
1211
import javax.inject.Provider;
1312
import java.nio.file.Files;
1413
import java.nio.file.Path;

jooby/src/main/java/io/jooby/TraceHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
import java.util.Map;
1111
import java.util.stream.Collectors;
1212

13+
/**
14+
* The TRACE method performs a message loop-back test along the path to the target resource.
15+
*
16+
* @author
17+
* @since 2.0.4
18+
*/
1319
public class TraceHandler implements Route.Decorator {
20+
private static final String CRLF = "\r\n";
21+
1422
@Nonnull @Override public Route.Handler apply(@Nonnull Route.Handler next) {
1523
return ctx -> {
1624
if (ctx.getMethod().equals(Router.TRACE)) {
1725
// Handle trace
18-
String CRLF = "\r\n";
1926
StringBuilder buffer = new StringBuilder(Router.TRACE).append(" ").append(ctx.pathString())
2027
.append(" ").append(ctx.getProtocol());
2128

modules/jooby-netty/src/main/java/io/jooby/netty/Netty.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public class Netty extends Server.Base {
4141
System.getProperty("io.netty.leakDetection.level", "disabled"));
4242
}
4343

44+
private static final int _50 = 50;
45+
46+
private static final int _100 = 100;
47+
4448
private List<Jooby> applications = new ArrayList<>();
4549

4650
private EventLoopGroup acceptorloop;
@@ -82,10 +86,10 @@ public class Netty extends Server.Base {
8286
NettyTransport transport = NettyTransport.transport(application.getClassLoader());
8387

8488
/** Acceptor event-loop */
85-
this.acceptorloop = transport.createEventLoop(1, "acceptor", 50);
89+
this.acceptorloop = transport.createEventLoop(1, "acceptor", _50);
8690

8791
/** Event loop: processing connections, parsing messages and doing engine's internal work */
88-
this.eventloop = transport.createEventLoop(options.getIoThreads(), "eventloop", 100);
92+
this.eventloop = transport.createEventLoop(options.getIoThreads(), "eventloop", _100);
8993

9094
/** File data factory: */
9195
HttpDataFactory factory = new DefaultHttpDataFactory(options.getBufferSize());

modules/jooby-test/src/main/java/io/jooby/MockContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ public MockContext setPathString(@Nonnull String pathString) {
232232
return files;
233233
}
234234

235+
/**
236+
* Set mock files.
237+
*
238+
* @param files Mock files.
239+
* @return This context.
240+
*/
235241
public MockContext setFiles(@Nonnull List<FileUpload> files) {
236242
this.files = files;
237243
return this;

0 commit comments

Comments
 (0)