summaryrefslogtreecommitdiff
path: root/src/main/java/foo/zaaarf/routecompass/Route.java
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2024-01-19 17:28:19 +0100
committer zaaarf <me@zaaarf.foo>2024-01-19 17:28:19 +0100
commit05f9c98dcd9ad2c7f94c261d2675e91a639ffb66 (patch)
tree6babd621a7b3a5584b2b98eb5e7481e25fc746b6 /src/main/java/foo/zaaarf/routecompass/Route.java
parente858d2017270da7e87bbaf362af028f4b788d321 (diff)
chore: added docs
Diffstat (limited to 'src/main/java/foo/zaaarf/routecompass/Route.java')
-rw-r--r--src/main/java/foo/zaaarf/routecompass/Route.java67
1 files changed, 62 insertions, 5 deletions
diff --git a/src/main/java/foo/zaaarf/routecompass/Route.java b/src/main/java/foo/zaaarf/routecompass/Route.java
index f56de0b..db1492a 100644
--- a/src/main/java/foo/zaaarf/routecompass/Route.java
+++ b/src/main/java/foo/zaaarf/routecompass/Route.java
@@ -4,18 +4,53 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMethod;
/**
- * Internal representation of a REST route.
+ * Representation of a REST route.
*/
public class Route {
- public final String route;
+ /**
+ * The path of the endpoint.
+ */
+ public final String path;
+
+ /**
+ * The supported {@link RequestMethod}s, flattened to a string.
+ */
public final String method;
+
+ /**
+ * The {@link MediaType} produced by the endpoint.
+ * May be null if not specified.
+ */
public final String produces;
+
+ /**
+ * The {@link MediaType} consumed by the endpoint.
+ * May be null if not specified.
+ */
public final String consumes;
+
+ /**
+ * Whether the endpoint is deprecated.
+ */
public final boolean deprecated;
+
+ /**
+ * An array of {@link Param}s, representing parameters accepted by the endpoint.
+ */
public final Param[] params;
- public Route(String route, RequestMethod[] methods, MediaType consumes, MediaType produces, boolean deprecated, Param... params) {
- this.route = route;
+ /**
+ * The one and only constructor.
+ * @param path the path of the endpoint
+ * @param methods the {@link RequestMethod}s accepted by the endpoint
+ * @param consumes the {@link MediaType} consumed by the endpoint, may be null
+ * @param produces the {@link MediaType} produced by the endpoint, may be null
+ * @param deprecated whether the endpoint is deprecated
+ * @param params {@link Param}s of the endpoint, may be null
+ */
+ public Route(String path, RequestMethod[] methods, MediaType consumes, MediaType produces, boolean deprecated,
+ Param... params) {
+ this.path = path;
StringBuilder methodStringBuilder = new StringBuilder("[");
for(RequestMethod m : methods)
@@ -35,14 +70,36 @@ public class Route {
this.deprecated = deprecated;
- this.params = params;
+ if(params != null) this.params = params;
+ else this.params = new Param[0]; //just in case
}
+ /**
+ * Representation of a parameter of a REST route.
+ */
public static class Param {
+ /**
+ * The fully-qualified name of the expected type of the parameter.
+ */
public final String typeFQN;
+
+ /**
+ * The name of the parameter.
+ */
public final String name;
+
+ /**
+ * The default value of the parameter.
+ * May be null, in which case the parameter is required.
+ */
public final String defaultValue;
+ /**
+ * The one and only constructor.
+ * @param typeFQN the FQN of the expected type of the parameter
+ * @param name the name of the parameter
+ * @param defaultValue the default value of the parameter, may be null if the parameter is required
+ */
public Param(String typeFQN, String name, String defaultValue) {
this.typeFQN = typeFQN;
this.name = name;