18
18
import com .google .auto .value .AutoValue ;
19
19
import com .google .common .collect .ImmutableSet ;
20
20
import java .util .HashMap ;
21
+ import java .util .List ;
21
22
import java .util .Map ;
22
23
import java .util .Set ;
24
+ import java .util .stream .Collectors ;
23
25
import javax .annotation .Nullable ;
24
26
25
27
@ AutoValue
@@ -63,6 +65,8 @@ public int compareTo(HttpBinding o) {
63
65
64
66
public abstract String pattern ();
65
67
68
+ public abstract List <String > additionalPatterns ();
69
+
66
70
public abstract Set <HttpBinding > pathParameters ();
67
71
68
72
public abstract Set <HttpBinding > queryParameters ();
@@ -84,8 +88,18 @@ public static HttpBindings.Builder builder() {
84
88
// in .proto file: "/global/instanceTemplates/{instance_template=*}"
85
89
// in .java file: "/global/instanceTemplates/{instanceTemplate=*}"
86
90
public String lowerCamelPattern () {
87
- String lowerCamelPattern = pattern ();
88
- for (HttpBinding pathParam : pathParameters ()) {
91
+ return lowerCamelPattern (pattern (), pathParameters ());
92
+ }
93
+
94
+ public List <String > lowerCamelAdditionalPatterns () {
95
+ return additionalPatterns ().stream ()
96
+ .map (a -> lowerCamelPattern (a , pathParameters ()))
97
+ .collect (Collectors .toList ());
98
+ }
99
+
100
+ private static String lowerCamelPattern (String originalPattern , Set <HttpBinding > pathParameters ) {
101
+ String lowerCamelPattern = originalPattern ;
102
+ for (HttpBinding pathParam : pathParameters ) {
89
103
lowerCamelPattern =
90
104
lowerCamelPattern .replaceAll (
91
105
"\\ {" + pathParam .name (), "{" + JavaStyle .toLowerCamelCase (pathParam .name ()));
@@ -107,6 +121,8 @@ public abstract static class Builder {
107
121
108
122
public abstract HttpBindings .Builder setPattern (String pattern );
109
123
124
+ public abstract HttpBindings .Builder setAdditionalPatterns (List <String > additionalPatterns );
125
+
110
126
abstract String pattern ();
111
127
112
128
public abstract HttpBindings .Builder setPathParameters (Set <HttpBinding > pathParameters );
0 commit comments