- * It is similar to Guava's {@code AsyncFunction}, redeclared so that Guava can be shaded. + *
It is similar to Guava's {@code AsyncFunction}, redeclared so that Guava can be shaded. */ public interface ApiAsyncFunction { /** * Returns an output Future to use in place of the given input. The output Future need not be * done, making AsyncFunction suitable for asynchronous derivations. * - *
- * Throwing an exception from this method is equivalent to returning a failing Future. + *
Throwing an exception from this method is equivalent to returning a failing Future.
*/
ApiFuture Clocks other than {@link NanoClock} are typically used only for testing.
*
- * This interface is required in addition to Java 8's Clock, because nanoTime is required to compare
- * values with io.grpc.CallOptions.getDeadlineNanoTime().
+ * This interface is required in addition to Java 8's Clock, because nanoTime is required to
+ * compare values with io.grpc.CallOptions.getDeadlineNanoTime().
*/
public interface ApiClock {
- /**
- * Returns the current value of this clock's high-resolution time source, in nanoseconds.
- */
+ /** Returns the current value of this clock's high-resolution time source, in nanoseconds. */
long nanoTime();
- /**
- * Returns the current value of this clock's high-resolution time source, in milliseconds.
- */
+ /** Returns the current value of this clock's high-resolution time source, in milliseconds. */
long millisTime();
}
diff --git a/src/main/java/com/google/api/core/ApiFunction.java b/src/main/java/com/google/api/core/ApiFunction.java
index 749b534a2..d03d93493 100644
--- a/src/main/java/com/google/api/core/ApiFunction.java
+++ b/src/main/java/com/google/api/core/ApiFunction.java
@@ -32,8 +32,7 @@
/**
* Legacy version of Function.
*
- *
- * It is similar to Guava's {@code Function}, redeclared so that Guava can be shaded.
+ * It is similar to Guava's {@code Function}, redeclared so that Guava can be shaded.
*/
public interface ApiFunction Similar to Guava's {@code ListenableFuture}, but redeclared so that Guava could be shaded.
*/
public interface ApiFuture
- * It is similar to Guava's {@code FutureCallback}, redeclared so that Guava can be shaded.
+ * It is similar to Guava's {@code FutureCallback}, redeclared so that Guava can be shaded.
*/
public interface ApiFutureCallback
- * The normal lifecycle of a service is:
+ * The normal lifecycle of a service is:
*
*
- * There are deviations from this if there are failures or if {@link ApiService#stopAsync} is called
- * before the {@link ApiService} reaches the {@linkplain State#RUNNING RUNNING} state. The set of
- * legal transitions form a DAG,
- * therefore every method of the listener will be called at most once. N.B. The {@link State#FAILED}
- * and {@link State#TERMINATED} states are terminal states, once a service enters either of these
- * states it cannot ever leave them.
+ * There are deviations from this if there are failures or if {@link ApiService#stopAsync} is
+ * called before the {@link ApiService} reaches the {@linkplain State#RUNNING RUNNING} state. The
+ * set of legal transitions form a DAG, therefore every method of the
+ * listener will be called at most once. N.B. The {@link State#FAILED} and {@link State#TERMINATED}
+ * states are terminal states, once a service enters either of these states it cannot ever leave
+ * them.
*
- *
- * Implementors of this interface are strongly encouraged to extend {@link AbstractApiService} which
- * implement this interface and make the threading and state management easier.
+ * Implementors of this interface are strongly encouraged to extend {@link AbstractApiService}
+ * which implement this interface and make the threading and state management easier.
*
- *
- * Similar to Guava's {@code Service}, but redeclared so that Guava could be shaded.
+ * Similar to Guava's {@code Service}, but redeclared so that Guava could be shaded.
*/
public interface ApiService {
/**
@@ -71,17 +68,15 @@ public interface ApiService {
* service changes state. The listener will not have previous state changes replayed, so it is
* suggested that listeners are added before the service starts.
*
- *
- * {@code addListener} guarantees execution ordering across calls to a given listener but not
+ * {@code addListener} guarantees execution ordering across calls to a given listener but not
* across calls to multiple listeners. Specifically, a given listener will have its callbacks
* invoked in the same order as the underlying service enters those states. Additionally, at most
* one of the listener's callbacks will execute at once. However, multiple listeners' callbacks
* may execute concurrently, and listeners may execute in an order different from the one in which
* they were registered.
*
- *
- * RuntimeExceptions thrown by a listener will be caught and logged. Any exception thrown during
- * {@code Executor.execute} (e.g., a {@code RejectedExecutionException}) will be caught and
+ * RuntimeExceptions thrown by a listener will be caught and logged. Any exception thrown
+ * during {@code Executor.execute} (e.g., a {@code RejectedExecutionException}) will be caught and
* logged.
*
* @param listener the listener to run when the service changes state is complete
@@ -93,8 +88,8 @@ public interface ApiService {
* Waits for the {@link ApiService} to reach the {@linkplain State#RUNNING running state}.
*
* @throws IllegalStateException if the service reaches a state from which it is not possible to
- * enter the {@link State#RUNNING} state. e.g. if the {@code state} is {@code State#TERMINATED}
- * when this method is called then this will throw an IllegalStateException.
+ * enter the {@link State#RUNNING} state. e.g. if the {@code state} is {@code
+ * State#TERMINATED} when this method is called then this will throw an IllegalStateException.
*/
void awaitRunning();
@@ -106,9 +101,8 @@ public interface ApiService {
* @param unit the time unit of the timeout argument
* @throws TimeoutException if the service has not reached the given state within the deadline
* @throws IllegalStateException if the service reaches a state from which it is not possible to
- * enter the {@link State#RUNNING RUNNING} state. e.g. if the {@code state} is
- * {@code State#TERMINATED} when this method is called then this will throw an
- * IllegalStateException.
+ * enter the {@link State#RUNNING RUNNING} state. e.g. if the {@code state} is {@code
+ * State#TERMINATED} when this method is called then this will throw an IllegalStateException.
*/
void awaitRunning(long timeout, TimeUnit unit) throws TimeoutException;
@@ -154,10 +148,10 @@ public interface ApiService {
/**
* If the service is {@linkplain State#STARTING starting} or {@linkplain State#RUNNING running},
- * this initiates service shutdown and returns immediately. If the service is
- * {@linkplain State#NEW new}, it is {@linkplain State#TERMINATED terminated} without having been
- * started nor stopped. If the service has already been stopped, this method returns immediately
- * without taking action.
+ * this initiates service shutdown and returns immediately. If the service is {@linkplain
+ * State#NEW new}, it is {@linkplain State#TERMINATED terminated} without having been started nor
+ * stopped. If the service has already been stopped, this method returns immediately without
+ * taking action.
*
* @return this
*/
@@ -166,9 +160,8 @@ public interface ApiService {
/**
* The lifecycle states of a service.
*
- *
- * The ordering of the {@link State} enum is defined such that if there is a state transition from
- * {@code A -> B} then {@code A.compareTo(B) < 0}. N.B. The converse is not true, i.e. if
+ * The ordering of the {@link State} enum is defined such that if there is a state transition
+ * from {@code A -> B} then {@code A.compareTo(B) < 0}. N.B. The converse is not true, i.e. if
* {@code A.compareTo(B) < 0} then there is not guaranteed to be a valid state transition
* {@code A -> B}.
*/
@@ -203,8 +196,7 @@ enum State {
* A listener for the various state changes that a {@link ApiService} goes through in its
* lifecycle.
*
- *
- * All methods are no-ops by default, implementors should override the ones they care about.
+ * All methods are no-ops by default, implementors should override the ones they care about.
*/
@BetaApi
abstract class Listener {
@@ -214,29 +206,29 @@ abstract class Listener {
* Therefore, if this method is called, no other methods will be called on the {@link Listener}.
*
* @param from The previous state that is being transitioned from. Failure can occur in any
- * state with the exception of {@linkplain State#NEW NEW} or {@linkplain State#TERMINATED
- * TERMINATED}.
+ * state with the exception of {@linkplain State#NEW NEW} or {@linkplain State#TERMINATED
+ * TERMINATED}.
* @param failure The exception that caused the failure.
*/
public void failed(State from, Throwable failure) {}
/**
- * Called when the service transitions from {@linkplain State#STARTING STARTING} to
- * {@linkplain State#RUNNING RUNNING}. This occurs when a service has successfully started.
+ * Called when the service transitions from {@linkplain State#STARTING STARTING} to {@linkplain
+ * State#RUNNING RUNNING}. This occurs when a service has successfully started.
*/
public void running() {}
/**
- * Called when the service transitions from {@linkplain State#NEW NEW} to
- * {@linkplain State#STARTING STARTING}. This occurs when {@link ApiService#startAsync} is
- * called the first time.
+ * Called when the service transitions from {@linkplain State#NEW NEW} to {@linkplain
+ * State#STARTING STARTING}. This occurs when {@link ApiService#startAsync} is called the first
+ * time.
*/
public void starting() {}
/**
* Called when the service transitions to the {@linkplain State#STOPPING STOPPING} state. The
- * only valid values for {@code from} are {@linkplain State#STARTING STARTING} or
- * {@linkplain State#RUNNING RUNNING}. This occurs when {@link ApiService#stopAsync} is called.
+ * only valid values for {@code from} are {@linkplain State#STARTING STARTING} or {@linkplain
+ * State#RUNNING RUNNING}. This occurs when {@link ApiService#stopAsync} is called.
*
* @param from The previous state that is being transitioned from.
*/
@@ -245,12 +237,12 @@ public void stopping(State from) {}
/**
* Called when the service transitions to the {@linkplain State#TERMINATED TERMINATED} state.
* The {@linkplain State#TERMINATED TERMINATED} state is a terminal state in the transition
- * diagram. Therefore, if this method is called, no other methods will be called on the
- * {@link Listener}.
+ * diagram. Therefore, if this method is called, no other methods will be called on the {@link
+ * Listener}.
*
* @param from The previous state that is being transitioned from. The only valid values for
- * this are {@linkplain State#NEW NEW}, {@linkplain State#RUNNING RUNNING} or
- * {@linkplain State#STOPPING STOPPING}.
+ * this are {@linkplain State#NEW NEW}, {@linkplain State#RUNNING RUNNING} or {@linkplain
+ * State#STOPPING STOPPING}.
*/
public void terminated(State from) {}
}
diff --git a/src/main/java/com/google/api/core/BetaApi.java b/src/main/java/com/google/api/core/BetaApi.java
index 0c1d349ee..4b6491b73 100644
--- a/src/main/java/com/google/api/core/BetaApi.java
+++ b/src/main/java/com/google/api/core/BetaApi.java
@@ -39,16 +39,16 @@
* Indicates a public API that can change at any time, and has no guarantee of API stability and
* backward-compatibility.
*
- *
- * Usage guidelines:
+ * Usage guidelines:
+ *
*
- * This annotation only makes sense on APIs that are not private. Its existence is necessary because
- * Java does not have a visibility level for code within a compilation unit.
+ * This annotation only makes sense on APIs that are not private. Its existence is necessary
+ * because Java does not have a visibility level for code within a compilation unit.
*
- *
- * Adding this annotation to an API is considered API-breaking.
+ * Adding this annotation to an API is considered API-breaking.
*/
@BetaApi
@Retention(RetentionPolicy.RUNTIME)
@@ -58,8 +56,6 @@
})
@Documented
public @interface InternalApi {
- /**
- * Context information such as "internal to library", "for testing", etc.
- */
+ /** Context information such as "internal to library", "for testing", etc. */
String value() default "";
}
diff --git a/src/main/java/com/google/api/core/InternalExtensionOnly.java b/src/main/java/com/google/api/core/InternalExtensionOnly.java
index 5b410e2c8..2304f77d6 100644
--- a/src/main/java/com/google/api/core/InternalExtensionOnly.java
+++ b/src/main/java/com/google/api/core/InternalExtensionOnly.java
@@ -39,20 +39,18 @@
* Indicates a public API that is stable for callers to use, but has no guarantee of stability for
* extension. Consequently, the API should only be extended within the package containing the API.
*
- *
- * For example:
+ * For example:
+ *
*
- * The list above is just for illustration purposes and is not exhaustive.
+ * The list above is just for illustration purposes and is not exhaustive.
*
- *
- * Adding this annotation to an API is considered API-breaking.
+ * Adding this annotation to an API is considered API-breaking.
*/
@BetaApi
@Retention(RetentionPolicy.RUNTIME)
@@ -66,8 +64,6 @@
})
@Documented
public @interface InternalExtensionOnly {
- /**
- * Context information on why the interface/class is annotated with InternalExtensionOnly.
- */
+ /** Context information on why the interface/class is annotated with InternalExtensionOnly. */
String value() default "";
}
diff --git a/src/main/java/com/google/api/core/ListenableFutureToApiFuture.java b/src/main/java/com/google/api/core/ListenableFutureToApiFuture.java
index 7bf9fabc4..fe77f56d3 100644
--- a/src/main/java/com/google/api/core/ListenableFutureToApiFuture.java
+++ b/src/main/java/com/google/api/core/ListenableFutureToApiFuture.java
@@ -32,9 +32,7 @@
import com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture;
import com.google.common.util.concurrent.ListenableFuture;
-/**
- * INTERNAL USE ONLY. Adapter from Guava ListenableFuture to ApiFuture.
- */
+/** INTERNAL USE ONLY. Adapter from Guava ListenableFuture to ApiFuture. */
@InternalApi
public class ListenableFutureToApiFuture
- * Templates use the syntax of the API platform; see the protobuf of HttpRule for details. A
+ * Templates use the syntax of the API platform; see the protobuf of HttpRule for details. A
* template consists of a sequence of literals, wildcards, and variable bindings, where each binding
- * can have a sub-path. A string representation can be parsed into an instance of
- * {@link PathTemplate}, which can then be used to perform matching and instantiation.
+ * can have a sub-path. A string representation can be parsed into an instance of {@link
+ * PathTemplate}, which can then be used to perform matching and instantiation.
*
- *
- * Matching and instantiation deals with unescaping and escaping using URL encoding rules. For
- * example, if a template variable for a single segment is instantiated with a string like
- * {@code "a/b"}, the slash will be escaped to {@code "%2f"}. (Note that slash will not be escaped
- * for a multiple-segment variable, but other characters will). The literals in the template itself
- * are not escaped automatically, and must be already URL encoded.
+ * Matching and instantiation deals with unescaping and escaping using URL encoding rules. For
+ * example, if a template variable for a single segment is instantiated with a string like {@code
+ * "a/b"}, the slash will be escaped to {@code "%2f"}. (Note that slash will not be escaped for a
+ * multiple-segment variable, but other characters will). The literals in the template itself are
+ * not escaped automatically, and must be already URL encoded.
*
- *
- * Here is an example for a template using simple variables:
+ * Here is an example for a template using simple variables:
*
*
- * For a variable which has no sub-path, this returns a path template with a single wildcard
+ * For a variable which has no sub-path, this returns a path template with a single wildcard
* ('*').
*
* @throws ValidationException if the variable does not exist in the template.
@@ -422,9 +417,7 @@ public void validate(String path, String exceptionMessagePrefix) {
throw new ValidationException(
String.format(
"%s: Parameter \"%s\" must be in the form \"%s\"",
- exceptionMessagePrefix,
- path,
- this.toString()));
+ exceptionMessagePrefix, path, this.toString()));
}
}
@@ -434,30 +427,27 @@ public void validate(String path, String exceptionMessagePrefix) {
* throws a ValidationException. The exceptionMessagePrefix parameter will be prepended to the
* ValidationException message.
*
- *
- * If the path starts with '//', the first segment will be interpreted as a host name and stored
- * in the variable {@link #HOSTNAME_VAR}.
+ * If the path starts with '//', the first segment will be interpreted as a host name and
+ * stored in the variable {@link #HOSTNAME_VAR}.
*
- *
- * See the {@link PathTemplate} class documentation for examples.
+ * See the {@link PathTemplate} class documentation for examples.
*
- *
- * For free wildcards in the template, the matching process creates variables named '$n', where
+ * For free wildcards in the template, the matching process creates variables named '$n', where
* 'n' is the wildcard's position in the template (starting at n=0). For example:
*
*
- * If the path starts with '//', the first segment will be interpreted as a host name and stored
- * in the variable {@link #HOSTNAME_VAR}.
+ * If the path starts with '//', the first segment will be interpreted as a host name and
+ * stored in the variable {@link #HOSTNAME_VAR}.
*
- *
- * See the {@link PathTemplate} class documentation for examples.
+ * See the {@link PathTemplate} class documentation for examples.
*
- *
- * For free wildcards in the template, the matching process creates variables named '$n', where
+ * For free wildcards in the template, the matching process creates variables named '$n', where
* 'n' is the wildcard's position in the template (starting at n=0). For example:
*
*
- * Note that free wildcards in the template must have bindings of '$n' variables, where 'n' is the
- * position of the wildcard (starting at 0). See the documentation of {@link #match(String)} for
- * details.
+ * Note that free wildcards in the template must have bindings of '$n' variables, where 'n' is
+ * the position of the wildcard (starting at 0). See the documentation of {@link #match(String)}
+ * for details.
*
* @throws ValidationException if a variable occurs in the template without a binding.
*/
@@ -721,10 +705,10 @@ public String instantiate(String... keysAndValues) {
* using their original syntax. Example:
*
*
- * A resource name is represented by {@link PathTemplate}, an assignment to variables in the
+ * A resource name is represented by {@link PathTemplate}, an assignment to variables in the
* template, and an optional endpoint. The {@code ResourceName} class implements the map interface
* (unmodifiable) to work with the variable assignments, and has methods to reproduce the string
* representation of the name, to construct new names, and to dereference names into resources.
*
- *
- * As a resource name essentially represents a match of a path template against a string, it can be
- * also used for other purposes than naming resources. However, not all provided methods may make
+ * As a resource name essentially represents a match of a path template against a string, it can
+ * be also used for other purposes than naming resources. However, not all provided methods may make
* sense in all applications.
*
- *
- * Usage examples:
+ * Usage examples:
*
*
- *
*
- *
- *
*/
@BetaApi
@@ -63,8 +63,6 @@
})
@Documented
public @interface BetaApi {
- /**
- * Context information such as links to a discussion thread, tracking issue, etc.
- */
+ /** Context information such as links to a discussion thread, tracking issue, etc. */
String value() default "";
}
diff --git a/src/main/java/com/google/api/core/InternalApi.java b/src/main/java/com/google/api/core/InternalApi.java
index 67161bcbd..80b76706c 100644
--- a/src/main/java/com/google/api/core/InternalApi.java
+++ b/src/main/java/com/google/api/core/InternalApi.java
@@ -39,12 +39,10 @@
* Annotates a program element (class, method, package etc) which is internal to its containing
* library, not part of the public API, and should not be used by users of the library.
*
- *
- *
*
- * {@code
- * PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
- * assert template.matches("v2/shelves") == false;
- * Map<String, String> values = template.match("v1/shelves/s1/books/b1");
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put("shelf", "s1");
- * expectedValues.put("book", "b1");
- * assert values.equals(expectedValues);
- * assert template.instantiate(values).equals("v1/shelves/s1/books/b1");
+ * PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
+ * assert template.matches("v2/shelves") == false;
+ * Map<String, String> values = template.match("v1/shelves/s1/books/b1");
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put("shelf", "s1");
+ * expectedValues.put("book", "b1");
+ * assert values.equals(expectedValues);
+ * assert template.instantiate(values).equals("v1/shelves/s1/books/b1");
* }
*
* Templates can use variables which match sub-paths. Example:
*
* {@code
- * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}"};
- * assert template.match("v1/shelves/books/b1") == null;
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put("name", "shelves/s1/books/b1");
- * assert template.match("v1/shelves/s1/books/b1").equals(expectedValues);
+ * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}"};
+ * assert template.match("v1/shelves/books/b1") == null;
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put("name", "shelves/s1/books/b1");
+ * assert template.match("v1/shelves/s1/books/b1").equals(expectedValues);
* }
*
* Path templates can also be used with only wildcards. Each wildcard is associated with an implicit
* variable {@code $n}, where n is the zero-based position of the wildcard. Example:
*
* {@code
- * PathTemplate template = PathTemplate.create("shelves/*/books/*"};
- * assert template.match("shelves/books/b1") == null;
- * Map<String, String> values = template.match("v1/shelves/s1/books/b1");
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put("$0", s1");
- * expectedValues.put("$1", "b1");
- * assert values.equals(expectedValues);
+ * PathTemplate template = PathTemplate.create("shelves/*/books/*"};
+ * assert template.match("shelves/books/b1") == null;
+ * Map<String, String> values = template.match("v1/shelves/s1/books/b1");
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put("$0", s1");
+ * expectedValues.put("$1", "b1");
+ * assert values.equals(expectedValues);
* }
*
* Paths input to matching can use URL relative syntax to indicate a host name by prefixing the host
@@ -108,14 +105,14 @@
* for URL relative syntax and simple path syntax:
*
* {@code
- * PathTemplate template = PathTemplate.create("shelves/*"};
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put(PathTemplate.HOSTNAME_VAR, "//somewhere.io");
- * expectedValues.put("$0", s1");
- * assert template.match("//somewhere.io/shelves/s1").equals(expectedValues);
- * expectedValues.clear();
- * expectedValues.put("$0", s1");
- * assert template.match("shelves/s1").equals(expectedValues);
+ * PathTemplate template = PathTemplate.create("shelves/*"};
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put(PathTemplate.HOSTNAME_VAR, "//somewhere.io");
+ * expectedValues.put("$0", s1");
+ * assert template.match("//somewhere.io/shelves/s1").equals(expectedValues);
+ * expectedValues.clear();
+ * expectedValues.put("$0", s1");
+ * assert template.match("shelves/s1").equals(expectedValues);
* }
*
* For the representation of a resource name see {@link TemplatedResourceName}, which is
@@ -124,9 +121,8 @@
public class PathTemplate {
/**
- * A constant identifying the special variable used for endpoint bindings in the result of
- * {@link #matchFromFullName(String)}. It may also contain protocol string, if its provided in the
- * input.
+ * A constant identifying the special variable used for endpoint bindings in the result of {@link
+ * #matchFromFullName(String)}. It may also contain protocol string, if its provided in the input.
*/
public static final String HOSTNAME_VAR = "$hostname";
@@ -347,16 +343,15 @@ public PathTemplate withoutVars() {
* Returns a path template for the sub-path of the given variable. Example:
*
* {@code
- * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}");
- * assert template.subTemplate("name").toString().equals("shelves/*/books/*");
+ * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}");
+ * assert template.subTemplate("name").toString().equals("shelves/*/books/*");
* }
*
* The returned template will never have named variables, but only wildcards, which are dealt with
- * in matching and instantiation using '$n'-variables. See the documentation of
- * {@link #match(String)} and {@link #instantiate(Map)}, respectively.
+ * in matching and instantiation using '$n'-variables. See the documentation of {@link
+ * #match(String)} and {@link #instantiate(Map)}, respectively.
*
- * {@code
- * PathTemplate template = PathTemplate.create("shelves/*/books/*");
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put("$0", "s1");
- * expectedValues.put("$1", "b1");
- * assert template.validatedMatch("shelves/s1/books/b2", "User exception string")
- * .equals(expectedValues);
- * expectedValues.clear();
- * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
- * expectedValues.put("$0", "s1");
- * expectedValues.put("$1", "b1");
- * assert template.validatedMatch("//somewhere.io/shelves/s1/books/b2", "User exception string")
- * .equals(expectedValues);
+ * PathTemplate template = PathTemplate.create("shelves/*/books/*");
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put("$0", "s1");
+ * expectedValues.put("$1", "b1");
+ * assert template.validatedMatch("shelves/s1/books/b2", "User exception string")
+ * .equals(expectedValues);
+ * expectedValues.clear();
+ * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
+ * expectedValues.put("$0", "s1");
+ * expectedValues.put("$1", "b1");
+ * assert template.validatedMatch("//somewhere.io/shelves/s1/books/b2", "User exception string")
+ * .equals(expectedValues);
* }
*
* All matched values will be properly unescaped using URL encoding rules (so long as URL encoding
@@ -469,9 +459,7 @@ public Map{@code
- * PathTemplate template = PathTemplate.create("shelves/*/books/*");
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put("$0", "s1");
- * expectedValues.put("$1", "b1");
- * assert template.match("shelves/s1/books/b2").equals(expectedValues);
- * expectedValues.clear();
- * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
- * expectedValues.put("$0", "s1");
- * expectedValues.put("$1", "b1");
- * assert template.match("//somewhere.io/shelves/s1/books/b2").equals(expectedValues);
+ * PathTemplate template = PathTemplate.create("shelves/*/books/*");
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put("$0", "s1");
+ * expectedValues.put("$1", "b1");
+ * assert template.match("shelves/s1/books/b2").equals(expectedValues);
+ * expectedValues.clear();
+ * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
+ * expectedValues.put("$0", "s1");
+ * expectedValues.put("$1", "b1");
+ * assert template.match("//somewhere.io/shelves/s1/books/b2").equals(expectedValues);
* }
*
* All matched values will be properly unescaped using URL encoding rules (so long as URL encoding
@@ -523,11 +508,11 @@ public Map{@code
- * Map<String, String> expectedValues = new HashMap<>();
- * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
- * expectedValues.put("name", "shelves/s1");
- * assert template("{name=shelves/*}").matchFromFullName("somewhere.io/shelves/s1")
- * .equals(expectedValues);
+ * Map<String, String> expectedValues = new HashMap<>();
+ * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
+ * expectedValues.put("name", "shelves/s1");
+ * assert template("{name=shelves/*}").matchFromFullName("somewhere.io/shelves/s1")
+ * .equals(expectedValues);
* }
*/
@Nullable
@@ -696,10 +681,9 @@ private static String concatCaptures(@Nullable String cur, String next) {
* Instantiate the template based on the given variable assignment. Performs proper URL escaping
* of variable assignments.
*
- * {@code
- * PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
- * Map<String, String> partialMap = new HashMap<>();
- * partialMap.put("shelf", "s1");
- * assert template.instantiatePartial(partialMap).equals("v1/shelves/s1/books/{book}");
+ * PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
+ * Map<String, String> partialMap = new HashMap<>();
+ * partialMap.put("shelf", "s1");
+ * assert template.instantiatePartial(partialMap).equals("v1/shelves/s1/books/{book}");
* }
*
* The result of this call can be used to create a new template.
@@ -1020,7 +1004,8 @@ private static boolean isSegmentBeginOrEndInvalid(String seg) {
// A segment can start with a delimiter, as long as there is no { right after it.
// A segment can end with a delimiter, as long as there is no } right before it.
// e.g. Invalid: .{well}-{known}, {well}-{known}-
- // Valid: .well-known, .well-{known}, .-~{well-known}, these segments are all considered as literals for matching
+ // Valid: .well-known, .well-{known}, .-~{well-known}, these segments are all considered as
+ // literals for matching
return (COMPLEX_DELIMITER_PATTERN.matcher(seg.substring(0, 1)).find() && seg.charAt(1) == '{')
|| (COMPLEX_DELIMITER_PATTERN.matcher(seg.substring(seg.length() - 1)).find()
&& seg.charAt(seg.length() - 2) == '}');
diff --git a/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java b/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java
index 98312e342..f448f9677 100644
--- a/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java
+++ b/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java
@@ -30,7 +30,6 @@
package com.google.api.pathtemplate;
-import com.google.api.core.BetaApi;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
@@ -43,25 +42,22 @@
/**
* Class for representing and working with resource names.
*
- * {@code
- * PathTemplate template = PathTemplate.create("shelves/*/books/*");
- * TemplatedResourceName resourceName = TemplatedResourceName.create(template, "shelves/s1/books/b1");
- * assert resourceName.get("$1").equals("b1");
- * assert resourceName.parentName().toString().equals("shelves/s1/books");
+ * PathTemplate template = PathTemplate.create("shelves/*/books/*");
+ * TemplatedResourceName resourceName = TemplatedResourceName.create(template, "shelves/s1/books/b1");
+ * assert resourceName.get("$1").equals("b1");
+ * assert resourceName.parentName().toString().equals("shelves/s1/books");
* }
*/
public class TemplatedResourceName implements Map