@Override public DiscoveryField getField(String key) { for (DiscoveryField field : getFields()) { // Just check each field's name without recursively searching inside each field. if (field.getNameAsParameter().equals(key)) { return field; } } return null; }
@Override public List<DiscoveryField> getFields() { return parentMethod().getInputFields(); }
@Override public String getTypeName() { return typeName(); }
public DiscoveryMethodModel(Method method, DiscoApiModel apiModel) { Preconditions.checkNotNull(method); this.method = method; this.apiModel = apiModel; String httpMethod = method.httpMethod().toUpperCase().trim(); hasExtraFieldMask = httpMethod.equals("PATCH") || httpMethod.equals("PUT"); if (hasExtraFieldMask) { fieldMaskField = createFieldMaskField(); } else { fieldMaskField = null; } this.inputType = DiscoveryRequestType.create(this); if (method.response() != null) { this.outputType = DiscoveryField.create(method.response(), apiModel); } else { this.outputType = EmptyTypeModel.getInstance(); } }
public static DiscoveryRequestType create(DiscoveryMethodModel method) { return newBuilder().typeName("message").parentMethod(method).build(); }
@Override public String getFullNameFor(TypeModel type) { if (type instanceof DiscoveryRequestType) { Method method = ((DiscoveryRequestType) type).parentMethod().getDiscoMethod(); return discoGapicNamer.getRequestTypeName(method, languageNamer).getFullName(); } return typeFormatter.getFullNameFor(type); }
@Override public TypeName getTypeName(TypeModel type) { if (type instanceof DiscoveryRequestType) { Method method = ((DiscoveryRequestType) type).parentMethod().getDiscoMethod(); return getDiscoGapicNamer().getRequestTypeName(method, getNamer()); } if (type.isEmptyType()) { return getTypeNameForElementType(type); } return getTypeName((DiscoveryField) type); }