Skip to content

Commit

Permalink
Add some missing javadocs to not generate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraLS3 committed Jan 6, 2024
1 parent 6fa2d0a commit bc4aef8
Show file tree
Hide file tree
Showing 67 changed files with 200 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ default boolean hasCapability(String capabilityName) {
return Capability.getByName(capabilityName).isPresent();
}

/**
* Singleton holder for listeners.
*/
class ListHolder {
static final AtomicReference<List<Consumer<Boolean>>> enableListeners = new AtomicReference<>(
new CopyOnWriteArrayList<>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ default Component fromLegacy(String legacy) {
* Converts the given input into a {@link Component}.
* Input example {@code §ctext}.
*
* @param legacy the input legacy
* @param legacy the input legacy
* @param character the character to use as the color prefix, usually {@code §}.
* @return a {@link Component}
* @see #fromLegacy(String)
Expand All @@ -115,7 +115,7 @@ default Component fromAdventureLegacy(String adventureLegacy) {
* Input example: {@code &#rrggbbtext}.
*
* @param adventureLegacy the input adventure legacy
* @param character the character to use as the color prefix, usually {@code &}.
* @param character the character to use as the color prefix, usually {@code &}.
* @return a {@link Component}
* @see #fromAdventureLegacy(String)
* @see Component#SECTION
Expand All @@ -139,7 +139,7 @@ default Component fromBungeeLegacy(String bungeeLegacy) {
* Input example: {@code §x§r§r§g§g§b§btext}.
*
* @param bungeeLegacy the input bungee legacy
* @param character the character to use as the color prefix, usually {@code §}.
* @param character the character to use as the color prefix, usually {@code §}.
* @return a {@link Component}
* @see Component#SECTION
* @see Component#AMPERSAND
Expand All @@ -164,6 +164,9 @@ default Component fromBungeeLegacy(String bungeeLegacy) {
*/
Component fromJson(String json);

/**
* Singleton holder for ComponentService.
*/
class Holder {
static final AtomicReference<ComponentService> service = new AtomicReference<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* PageExtension API for extending the webserver and the website.
*
* <a href="https://github.com/plan-player-analytics/Plan/wiki/APIv5-PageExtension-API">Documentation</a>
*/
package com.djrapitops.plan.delivery.web;
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public final class CompositeResolver implements Resolver {
this.resolvers = new ArrayList<>();
}

/**
* Create a new builder for a .
*
* @return a builder.
*/
public static CompositeResolver.Builder builder() {
return new Builder();
}
Expand Down Expand Up @@ -100,6 +105,9 @@ public boolean requiresAuth(Request request) {
return getResolver(forThis.getPath()).map(resolver -> resolver.requiresAuth(forThis)).orElse(true);
}

/**
* Builder class for {@link CompositeResolver}.
*/
public static class Builder {
private final CompositeResolver composite;

Expand Down Expand Up @@ -132,6 +140,11 @@ public Builder add(String prefix, Function<Request, Response> resolver, Predicat
return this;
}

/**
* Build the final result after adding all resolvers.
*
* @return The {@link CompositeResolver}
*/
public CompositeResolver build() {
return composite;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@
import java.util.function.Function;
import java.util.function.Predicate;

/**
* Utility class for constructing a {@link Resolver} with Functional Interfaces.
*/
public class FunctionalResolverWrapper implements Resolver {

private final Function<Request, Optional<Response>> resolver;
private final Predicate<Request> accessCheck;

/**
* Default constructor.
*
* @param resolver Function that solves the {@link Request} into an Optional {@link Response}.
* @param accessCheck Predicate that checks if {@link Request} is allowed or if 403 Forbidden should be given.
*/
public FunctionalResolverWrapper(Function<Request, Optional<Response>> resolver, Predicate<Request> accessCheck) {
this.resolver = resolver;
this.accessCheck = accessCheck;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,21 @@ default Set<String> usedWebPermissions() {
*/
Optional<Response> resolve(Request request);

/**
* Creates a new {@link ResponseBuilder} for a {@link Response}.
*
* @return a new builder.
*/
default ResponseBuilder newResponseBuilder() {
return Response.builder();
}

/**
* Used to check if the resolver requires authentication to be used.
*
* @param request Incoming request that you can use to figure out if authentication is required.
* @return true if you want 401 to be given when user has not logged in.
*/
default boolean requiresAuth(Request request) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ResponseBuilder {
/**
* Set MIME Type of the Response.
*
* @param mimeType MIME type of the Response https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
* @param mimeType MIME type of the Response <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">Documentation</a>
* @return this builder.
* @see MimeType for common MIME types.
*/
Expand All @@ -46,7 +46,7 @@ public ResponseBuilder setMimeType(String mimeType) {
* <p>
* Default status code is 200 (OK) if not set.
*
* @param code 1xx, 2xx, 3xx, 4xx, 5xx, https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
* @param code 1xx, 2xx, 3xx, 4xx, 5xx, <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status">Documentation</a>
* @return this builder.
*/
public ResponseBuilder setStatus(int code) {
Expand All @@ -57,7 +57,7 @@ public ResponseBuilder setStatus(int code) {
/**
* Set HTTP Response header.
*
* @param header Key of the header. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
* @param header Key of the header. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">Documentation</a>
* @param value Value for the header.
* @return this builder.
*/
Expand All @@ -75,7 +75,7 @@ protected ResponseBuilder removeHeader(String header) {
* Utility method for building redirects.
*
* @param url URL to redirect the client to with 302 Found.
* @return https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location
* @return <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location">Documentation</a>
*/
public ResponseBuilder redirectTo(String url) {
return setStatus(302).setHeader("Location", url).setContent(new byte[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
*/
public class BadRequestException extends IllegalArgumentException {

/**
* Default constructor.
*
* @param message Error message - avoid including any input incoming in the request to prevent XSS.
*/
public BadRequestException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Classes for implementing functionality with {@link com.djrapitops.plan.delivery.web.ResolverService}.
*
* <a href="https://github.com/plan-player-analytics/Plan/wiki/APIv5-PageExtension-API#resolverservice">Documentation</a>
*/
package com.djrapitops.plan.delivery.web.resolver;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class Request {
* @param path Requested path /example/target
* @param query Request parameters ?param=value etc
* @param user Web user doing the request (if authenticated)
* @param headers Request headers https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
* @param headers Request headers <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">Documentation</a>
* @param requestBody Raw body as bytes, if present
*/
public Request(String method, URIPath path, URIQuery query, WebUser user, Map<String, String> headers, byte[] requestBody) {
Expand All @@ -57,6 +57,11 @@ public Request(String method, URIPath path, URIQuery query, WebUser user, Map<St

/**
* Special constructor that figures out URIPath and URIQuery from "/path/and?query=params" and has no request body.
*
* @param method HTTP requst method
* @param target The requested path and query, e.g. "/path/and?query=params"
* @param user User that made the request
* @param headers HTTP request headers
*/
public Request(String method, String target, WebUser user, Map<String, String> headers) {
this.method = method;
Expand Down Expand Up @@ -121,7 +126,7 @@ public Optional<WebUser> getUser() {
/**
* Get a header in the request.
*
* @param key https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
* @param key <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">Documentation</a>
* @return Value if it is present in the request.
*/
public Optional<String> getHeader(String key) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Classes for implementing functionality with {@link com.djrapitops.plan.delivery.web.ResourceService}.
*
* <a href="https://github.com/plan-player-analytics/Plan/wiki/APIv5-PageExtension-API#resourceservice">Documentation</a>
*/
package com.djrapitops.plan.delivery.web.resource;
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ default ExtensionDataBuilder newExtensionDataBuilder() {
* <p>
* Requires Capability DATA_EXTENSION_BUILDER_API
*
* @param text Text that is displayed next to the value.
* @return new builder.
*/
default ValueBuilder valueBuilder(String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ static ExtensionService getInstance() {
*/
void unregister(DataExtension extension);

/**
* Singleton holder for {@link ExtensionService}.
*/
class Holder {
static final AtomicReference<ExtensionService> service = new AtomicReference<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public enum FormatType {
*/
NONE;

/**
* Get a format type by the enum name without exception.
*
* @param name FormatType#name()
* @return Optional if the format type is found by that name, empty if not found.
*/
public static Optional<FormatType> getByName(String name) {
if (name == null) {
return Optional.empty();
Expand All @@ -51,4 +57,5 @@ public static Optional<FormatType> getByName(String name) {
} catch (IllegalArgumentException e) {
return Optional.empty();
}
}}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
*/
public interface Group {

/**
* Get the name of the group.
*
* @return Name of the group given by a {@link com.djrapitops.plan.extension.annotation.GroupProvider}, e.g. "Miner"
*/
String getGroupName();

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
/**
* Name of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Name of the icon, if name is not valid no icon is shown.
*/
Expand All @@ -98,7 +98,7 @@
/**
* Family of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
/**
* Name of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Name of the icon, if name is not valid no icon is shown.
*/
Expand All @@ -85,7 +85,7 @@
/**
* Family of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
/**
* Name of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Name of the icon, if name is not valid no icon is shown.
*/
Expand All @@ -76,7 +76,7 @@
/**
* Family of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
/**
* Name of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Name of the icon, if name is not valid no icon is shown.
*/
Expand All @@ -71,7 +71,7 @@
/**
* Family of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
*/
String value();

/**
* Multiple {@link InvalidateMethod} annotations are supported per class.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Multiple {

/**
* All the annotations.
*
* @return All InvalidateMethod annotations in the class.
*/
InvalidateMethod[] value();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
/**
* Name of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Name of the icon, if name is not valid no icon is shown.
*/
Expand All @@ -88,7 +88,7 @@
/**
* Family of Font Awesome icon.
* <p>
* See https://fontawesome.com/icons (select 'free')) for icons and their {@link Family}.
* See <a href="https://fontawesome.com/icons">FontAwesome</a> (select 'free')) for icons and their {@link Family}.
*
* @return Family that matches an icon, if there is no icon for this family no icon is shown.
*/
Expand Down
Loading

0 comments on commit bc4aef8

Please sign in to comment.