use of com.google.api.codegen.util.TypeNameConverter in project toolkit by googleapis.
the class DiscoGapicNamer method getRequestMessageFullName.
/**
* Get the language-independent request message name from a method.
*/
public String getRequestMessageFullName(Method method, String defaultPackageName) {
// TODO remove reference to Java formatting - it is accidental that the fully-qualified
// message type matches the fully-qualified Java type
TypeNameConverter typeNameConverter = new JavaTypeTable(defaultPackageName);
JavaNameFormatter nameFormatter = new JavaNameFormatter();
return typeNameConverter.getTypeNameInImplicitPackage(nameFormatter.publicClassName(DiscoGapicParser.getRequestName(method))).getFullName();
}
use of com.google.api.codegen.util.TypeNameConverter in project toolkit by googleapis.
the class CSharpSurfaceNamer method getOptionalFieldDefaultValue.
@Override
public String getOptionalFieldDefaultValue(FieldConfig fieldConfig, MethodContext context) {
// Need to provide defaults for primitives, enums, strings, and repeated (including maps)
FieldModel type = fieldConfig.getField();
if (context.getFeatureConfig().useResourceNameFormatOption(fieldConfig)) {
if (type.isRepeated()) {
TypeNameConverter typeNameConverter = getTypeNameConverter();
TypeName elementTypeName = typeNameConverter.getTypeName(getResourceTypeName(fieldConfig.getResourceNameConfig()));
TypeName enumerableTypeName = typeNameConverter.getTypeName("System.Linq.Enumerable");
TypeName emptyTypeName = new TypeName(enumerableTypeName.getFullName(), enumerableTypeName.getNickname(), "%s.Empty<%i>", elementTypeName);
return TypedValue.create(emptyTypeName, "%s()").getValueAndSaveTypeNicknameIn((CSharpTypeTable) typeNameConverter);
} else {
return null;
}
} else {
if (type.isPrimitive() || type.isEnum() || type.isRepeated()) {
return context.getTypeTable().getImplZeroValueAndSaveNicknameFor(type);
} else {
return null;
}
}
}
Aggregations