diff --git a/CHANGELOG.md b/CHANGELOG.md index f53bb2ac8..410ecb87d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [2.1.1](https://www.github.com/googleapis/api-common-java/compare/v2.1.0...v2.1.1) (2021-11-10) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_annotations to v2.10.0 ([#316](https://www.github.com/googleapis/api-common-java/issues/316)) ([99df091](https://www.github.com/googleapis/api-common-java/commit/99df0919c7901948a90cc411fc212468a7754c01)) + ## [2.1.0](https://www.github.com/googleapis/api-common-java/compare/v2.0.5...v2.1.0) (2021-10-20) diff --git a/build.gradle b/build.gradle index 04f955686..d25359a92 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin' group = "com.google.api" archivesBaseName = "api-common" -project.version = "2.1.0" // {x-version-update:api-common:current} +project.version = "2.1.1" // {x-version-update:api-common:current} sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -46,7 +46,7 @@ ext { auto_value_annotations: 'com.google.auto.value:auto-value-annotations:1.8.2', guava: 'com.google.guava:guava:31.0.1-jre', jsr305: 'com.google.code.findbugs:jsr305:3.0.2', - error_prone_annotations: 'com.google.errorprone:error_prone_annotations:2.9.0', + error_prone_annotations: 'com.google.errorprone:error_prone_annotations:2.10.0', // Testing junit: 'junit:junit:4.13.2', @@ -354,6 +354,9 @@ task javadocCombinedV3(type: Javadoc) { options.addStringOption("doclet", "com.microsoft.doclet.DocFxDoclet") options.addStringOption("projectname", "api-common") options.docletpath = [file(System.getenv('KOKORO_GFILE_DIR') + "/java-docfx-doclet-1.3.0.jar")] + // Newer Gradle 6 passes -notimestamp by default, which the doclet above doesn't understand: + // https://github.com/gradle/gradle/issues/11898 + options.noTimestamp false } clean { diff --git a/src/main/java/com/google/api/pathtemplate/PathTemplate.java b/src/main/java/com/google/api/pathtemplate/PathTemplate.java index 098524210..4e4e770e6 100644 --- a/src/main/java/com/google/api/pathtemplate/PathTemplate.java +++ b/src/main/java/com/google/api/pathtemplate/PathTemplate.java @@ -69,7 +69,7 @@ *
* Here is an example for a template using simple variables: * - *
+ ** * Templates can use variables which match sub-paths. Example: * - *{@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"); @@ -78,22 +78,22 @@ * expectedValues.put("book", "b1"); * assert values.equals(expectedValues); * assert template.instantiate(values).equals("v1/shelves/s1/books/b1"); - *+ * }
+ ** * 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("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); - *+ * }
+ ** * Paths input to matching can use URL relative syntax to indicate a host name by prefixing the host * name, as in {@code //somewhere.io/some/path}. The host name is matched into the special variable * {@link #HOSTNAME_VAR}. Patterns are agnostic about host names, and the same pattern can be used * for URL relative syntax and simple path syntax: * - *{@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"); @@ -101,14 +101,14 @@ * expectedValues.put("$0", s1"); * expectedValues.put("$1", "b1"); * assert values.equals(expectedValues); - *+ * }
+ ** * For the representation of a resource name see {@link TemplatedResourceName}, which is * based on path templates. @@ -347,10 +347,10 @@ public PathTemplate withoutVars() { /** * Returns a path template for the sub-path of the given variable. Example: * - *{@code * PathTemplate template = PathTemplate.create("shelves/*"}; * Map<String, String> expectedValues = new HashMap<>(); * expectedValues.put(PathTemplate.HOSTNAME_VAR, "//somewhere.io"); @@ -117,7 +117,7 @@ * expectedValues.clear(); * expectedValues.put("$0", s1"); * assert template.match("shelves/s1").equals(expectedValues); - *+ * }
+ ** * 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 @@ -446,7 +446,7 @@ public void validate(String path, String exceptionMessagePrefix) { * 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: * - *{@code * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}"); * assert template.subTemplate("name").toString().equals("shelves/*/books/*"); - *+ * }
+ ** * All matched values will be properly unescaped using URL encoding rules (so long as URL encoding * has not been disabled by the {@link #createWithoutUrlEncoding} method). @@ -498,7 +498,7 @@ public boolean matches(String path) { * 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: * - *{@code * PathTemplate template = PathTemplate.create("shelves/*/books/*"); * Map<String, String> expectedValues = new HashMap<>(); * expectedValues.put("$0", "s1"); @@ -459,7 +459,7 @@ public void validate(String path, String exceptionMessagePrefix) { * 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 * has not been disabled by the {@link #createWithoutUrlEncoding} method). @@ -523,13 +523,13 @@ public Map{@code * PathTemplate template = PathTemplate.create("shelves/*/books/*"); * Map<String, String> expectedValues = new HashMap<>(); * expectedValues.put("$0", "s1"); @@ -509,7 +509,7 @@ public boolean matches(String path) { * expectedValues.put("$0", "s1"); * expectedValues.put("$1", "b1"); * assert template.match("//somewhere.io/shelves/s1/books/b2").equals(expectedValues); - *+ * }
+ **/ @Nullable 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); - *+ * }
+ ** * The result of this call can be used to create a new template. */ diff --git a/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java b/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java index bbbedeaeb..c5e9cd6e1 100644 --- a/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java +++ b/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java @@ -58,12 +58,12 @@ *{@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}"); - *+ * }
* Usage examples: * - *
+ **/ public class TemplatedResourceName implements Map{@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"); - *+ * }