Skip to content

Commit f63e3eb

Browse files
committed
fix: format
1 parent 67168ad commit f63e3eb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

sdk-platform-java/api-common-java/src/main/java/com/google/api/pathtemplate/PathTemplate.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public String getCanonicalResourceName(Set<String> knownResources) {
358358
// Searching backwards allows us to stop immediately once the last valid pair is found.
359359
for (int i = segments.size() - 1; i >= 0; i--) {
360360
Segment seg = segments.get(i);
361-
361+
362362
// We are looking for the end of a binding (e.g., "}" in "{project}" or "{name=projects/*}")
363363
if (seg.kind() == SegmentKind.END_BINDING) {
364364
int bindingStartIndex = -1;
@@ -378,11 +378,13 @@ public String getCanonicalResourceName(Set<String> knownResources) {
378378
}
379379

380380
if (bindingStartIndex != -1) {
381-
// 1. If the binding contains any literals, it is considered a valid named resource binding.
381+
// 1. If the binding contains any literals, it is considered a valid named resource
382+
// binding.
382383
if (literalCountInBinding > 0) {
383384
isValidPair = true;
384385
} else if (bindingStartIndex > 0) {
385-
// 2. For simple bindings like "{project}", the binding itself has no inner literal resources.
386+
// 2. For simple bindings like "{project}", the binding itself has no inner literal
387+
// resources.
386388
// Instead, we check if the literal segment immediately preceding it (e.g., "projects/")
387389
// is a known resource.
388390
Segment prevSeg = segments.get(bindingStartIndex - 1);
@@ -392,7 +394,8 @@ public String getCanonicalResourceName(Set<String> knownResources) {
392394
}
393395

394396
if (isValidPair) {
395-
// We successfully found the last valid binding! Record its end index and terminate the search.
397+
// We successfully found the last valid binding! Record its end index and terminate the
398+
// search.
396399
lastValidEndBindingIndex = i;
397400
break;
398401
}

sdk-platform-java/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
import java.util.function.BiFunction;
9797
import java.util.function.Function;
9898
import java.util.function.Predicate;
99+
import java.util.regex.Pattern;
99100
import java.util.stream.Collectors;
100101
import javax.annotation.Generated;
101102
import javax.annotation.Nullable;
@@ -1632,7 +1633,9 @@ protected LambdaExpr createResourceNameExtractorClassInstance(
16321633
// For each httpBinding,
16331634
// generates resourceNameSegments.put("field",String.valueOf(request.getField()));
16341635
for (HttpBindings.HttpBinding httpBinding : httpBindings) {
1635-
if (!canonicalPath.contains(httpBinding.name())) {
1636+
if (!Pattern.compile("\\{" + httpBinding.name() + "(?:=.*?)?\\}")
1637+
.matcher(canonicalPath)
1638+
.find()) {
16361639
continue;
16371640
}
16381641
MethodInvocationExpr getFieldExpr =

0 commit comments

Comments
 (0)