/** * Get the input type of the underlying method. */ public TypeRef getInputType() { return method.getInputType(); }
/** * Get the input type of the underlying method. */ public TypeRef getInputType() { return method.getInputType(); }
@Override public String getAndSaveRequestTypeName(ImportTypeTable typeTable, SurfaceNamer surfaceNamer) { return ((ModelTypeTable) typeTable).getAndSaveNicknameFor(method.getInputType()); }
@Override public List<ProtoField> getInputFields() { if (inputFields != null) { return inputFields; } ImmutableList.Builder<ProtoField> fieldsBuilder = ImmutableList.builder(); for (Field field : method.getInputType().getMessageType().getFields()) { fieldsBuilder.add(new ProtoField(field)); } inputFields = fieldsBuilder.build(); return inputFields; }
@Override public String getInputFullName() { return method.getInputType().getMessageType().getFullName(); }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); } }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); } }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); }
public ProtoMethodModel(Method method) { Preconditions.checkNotNull(method); this.method = method; this.inputType = ProtoTypeRef.create(method.getInputType()); this.outputType = ProtoTypeRef.create(method.getOutputType()); }
private List<String> bidiStreamingReturnDocLines(Method method) { return ImmutableList.<String>builder() .add( "@returns {Stream}", " An object stream which is both readable and writable. It accepts objects", " representing " + commentReformatter.getLinkedElementName(method.getInputType().getMessageType()) + " for write() method, and", " will emit objects representing " + commentReformatter.getLinkedElementName(method.getOutputType().getMessageType()) + " on 'data' event asynchronously.") .build(); }
public List<HeaderRequestParamView> generateHeaderRequestParams(MethodContext context) { if (!context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) { return ImmutableList.of(); } GapicMethodConfig methodConfig = (GapicMethodConfig) context.getMethodConfig(); Method method = methodConfig.getMethod(); SurfaceNamer namer = context.getNamer(); if (method.getInputType() == null || !method.getInputType().isMessage()) { return ImmutableList.of(); } ImmutableList.Builder<HeaderRequestParamView> headerRequestParams = ImmutableList.builder(); MessageType inputMessageType = method.getInputType().getMessageType(); for (String headerRequestParam : methodConfig.getHeaderRequestParams()) { headerRequestParams.add( generateHeaderRequestParam(headerRequestParam, inputMessageType, namer)); } return headerRequestParams.build(); }
@Override public ProtoField getInputField(String fieldName) { Field inputField = method.getInputType().getMessageType().lookupField(fieldName); return inputField == null ? null : new ProtoField(inputField); }
@Override public GenericFieldSelector getInputFieldSelector(String fieldName) { return new ProtoFieldSelector( FieldSelector.resolve(method.getInputType().getMessageType(), fieldName)); }
@Override public TypeName getInputTypeName(ImportTypeTable typeTable) { return typeTable .getTypeTable() .getTypeName(((ModelTypeTable) typeTable).getFullNameFor(method.getInputType())); }
/** Resolves a field path into a field selector. */ FieldSelector resolveFieldPath(Method method, String fieldPath) { FieldSelector result = null; try { result = FieldSelector.resolve(method.getInputType().getMessageType(), fieldPath); if (result == null) { error( method.getLocation(), "undefined field '%s' on message '%s'.", fieldPath, getInputMessageName(method)); } } catch (RuntimeException exception) { error(method.getLocation(), "%s", exception.getMessage()); } return result; }
/** Resolves a field path into a field selector. */ FieldSelector resolveFieldPath(Method method, String fieldPath) { FieldSelector result = null; try { result = FieldSelector.resolve(method.getInputType().getMessageType(), fieldPath); if (result == null) { error( method.getLocation(), "undefined field '%s' on message '%s'.", fieldPath, getInputMessageName(method)); } } catch (RuntimeException exception) { error(method.getLocation(), "%s", exception.getMessage()); } return result; }
private void addMethodImports(GapicMethodContext context) { ModelTypeTable typeTable = context.getTypeTable(); GapicMethodConfig methodConfig = context.getMethodConfig(); if (methodConfig.isLongRunningOperation()) { typeTable.getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getReturnType()); typeTable.getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getMetadataType()); } typeTable.getAndSaveNicknameFor(context.getMethod().getInputType()); addFieldsImports(typeTable, methodConfig.getRequiredFields()); addFieldsImports(typeTable, methodConfig.getOptionalFields()); }
private InitCodeContext.Builder getContextBuilder() { return InitCodeContext.newBuilder() .symbolTable(new SymbolTable()) .initObjectType(ProtoTypeRef.create(method.getInputType())) .suggestedName(Name.from("request")); }
private void addMethodImports(GapicMethodContext context) { ModelTypeTable typeTable = context.getTypeTable(); GapicMethodConfig methodConfig = context.getMethodConfig(); if (methodConfig.isLongRunningOperation()) { typeTable.getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getReturnType()); typeTable.getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getMetadataType()); } typeTable.getAndSaveNicknameFor(context.getMethod().getInputType()); addFieldsImports(typeTable, methodConfig.getRequiredFields()); addFieldsImports(typeTable, methodConfig.getOptionalFields()); }