22
22
import com .google .api .generator .engine .ast .StringObjectValue ;
23
23
import com .google .api .generator .engine .ast .TypeNode ;
24
24
import com .google .api .generator .engine .ast .ValueExpr ;
25
+ import com .google .api .generator .engine .ast .Variable ;
25
26
import com .google .api .generator .engine .ast .VariableExpr ;
26
27
import com .google .api .generator .gapic .model .Field ;
27
28
import com .google .api .generator .gapic .model .Message ;
32
33
import com .google .common .base .Preconditions ;
33
34
import com .google .longrunning .Operation ;
34
35
import com .google .protobuf .Any ;
36
+ import com .google .protobuf .ByteString ;
35
37
import java .util .ArrayList ;
36
38
import java .util .Arrays ;
37
39
import java .util .HashMap ;
@@ -44,6 +46,8 @@ public class DefaultValueComposer {
44
46
private static TypeNode OPERATION_TYPE =
45
47
TypeNode .withReference (ConcreteReference .withClazz (Operation .class ));
46
48
private static TypeNode ANY_TYPE = TypeNode .withReference (ConcreteReference .withClazz (Any .class ));
49
+ private static TypeNode BYTESTRING_TYPE =
50
+ TypeNode .withReference (ConcreteReference .withClazz (ByteString .class ));
47
51
48
52
static Expr createDefaultValue (
49
53
MethodArgument methodArg , Map <String , ResourceName > resourceNames ) {
@@ -122,6 +126,13 @@ static Expr createDefaultValue(Field f) {
122
126
PrimitiveValue .builder ().setType (f .type ()).setValue ("true" ).build ());
123
127
}
124
128
129
+ if (f .type ().equals (BYTESTRING_TYPE )) {
130
+ return VariableExpr .builder ()
131
+ .setStaticReferenceType (BYTESTRING_TYPE )
132
+ .setVariable (Variable .builder ().setName ("EMPTY" ).setType (BYTESTRING_TYPE ).build ())
133
+ .build ();
134
+ }
135
+
125
136
throw new UnsupportedOperationException (
126
137
String .format (
127
138
"Default value for field %s with type %s not implemented yet." , f .name (), f .type ()));
0 commit comments