/** Return the names of required parameters of a method. */ public List<String> getRequiredFields(Method method) { MessageType inputMessage = method.getInputMessage(); return inputMessage .getFields() .stream() .filter(this::isFieldRequired) .map(Field::getSimpleName) .collect(Collectors.toList()); }
if (defaultResourceNameTreatment == ResourceNameTreatment.UNSET_TREATMENT && method .getInputMessage() .getFields() .stream() || !Strings.isNullOrEmpty(protoParser.getResourceOrSetEntityName(f)))) { String methodInputPackageName = protoParser.getProtoPackage(((ProtoFile) method.getInputMessage().getParent())); if (defaultPackageName.equals(methodInputPackageName)) { defaultResourceNameTreatment = ResourceNameTreatment.STATIC_TYPES;
@Visits void reach(Method method) { mustBeInScope(method, method.getInputMessage()); mustBeInScope(method, method.getOutputMessage()); markAsReachable(method); // Check whether any HTTP bounded fields are visible. HttpAttribute http = method.getAttribute(HttpAttribute.KEY); if (http != null) { for (HttpAttribute binding : http.getAllBindings()) { Iterable<FieldSelector> selectors = binding.getPathSelectors(); if (!binding.bodyCapturesUnboundFields()) { // Only add body fields if '*' is not used, otherwise they aren't required. selectors = Iterables.concat(selectors, binding.getBodySelectors()); } for (FieldSelector selector : selectors) { for (Field field : selector.getFields()) { if (!isReachable(field)) { errorSince( 2, field, "Field '%s' required by HTTP binding of method '%s' cannot be hidden. %s.", field.getFullName(), method.getFullName(), reasonForUnreachable(field)); } } } } } }
@Visits void reach(Method method) { mustBeInScope(method, method.getInputMessage()); mustBeInScope(method, method.getOutputMessage()); markAsReachable(method); // Check whether any HTTP bounded fields are visible. HttpAttribute http = method.getAttribute(HttpAttribute.KEY); if (http != null) { for (HttpAttribute binding : http.getAllBindings()) { Iterable<FieldSelector> selectors = binding.getPathSelectors(); if (!binding.bodyCapturesUnboundFields()) { // Only add body fields if '*' is not used, otherwise they aren't required. selectors = Iterables.concat(selectors, binding.getBodySelectors()); } for (FieldSelector selector : selectors) { for (Field field : selector.getFields()) { if (!isReachable(field)) { errorSince( 2, field, "Field '%s' required by HTTP binding of method '%s' cannot be hidden. %s.", field.getFullName(), method.getFullName(), reasonForUnreachable(field)); } } } } } }
Mockito.when(createShelvesMethod.getOutputType()).thenReturn(TypeRef.of(createShelvesResponse)); Mockito.doReturn(shelfMessage).when(createShelvesMethod).getInputMessage(); Mockito.doReturn(bookMessage).when(insertBook).getInputMessage(); Mockito.doReturn(protoFile).when(bookMessage).getParent();
private void startMergeMethod(Interface including, Method method) { // Check conditions implied by mixin configuration. Method redeclared = including.lookupMethod(method.getSimpleName()); if (redeclared == null) { error( including.getLocation(), "The API '%s' does not redeclare method '%s' as required by the mixin configuration.", including.getFullName(), method); return; } if (!method.getInputType().equals(redeclared.getInputType())) { error( redeclared.getLocation(), "The method '%s' must have request type '%s' as required by the mixin configuration.", redeclared, method.getInputMessage()); return; } if (!method.getOutputType().equals(redeclared.getOutputType())) { error( redeclared.getLocation(), "The method '%s' must have response type '%s' as required by the mixin configuration.", redeclared, method.getOutputType()); return; } // Add attribute. redeclared.addAttribute(ImplementsAttribute.KEY, ImplementsAttribute.create(method)); }
private void startMergeMethod(Interface including, Method method) { // Check conditions implied by mixin configuration. Method redeclared = including.lookupMethod(method.getSimpleName()); if (redeclared == null) { error( including.getLocation(), "The API '%s' does not redeclare method '%s' as required by the mixin configuration.", including.getFullName(), method); return; } if (!method.getInputType().equals(redeclared.getInputType())) { error( redeclared.getLocation(), "The method '%s' must have request type '%s' as required by the mixin configuration.", redeclared, method.getInputMessage()); return; } if (!method.getOutputType().equals(redeclared.getOutputType())) { error( redeclared.getLocation(), "The method '%s' must have response type '%s' as required by the mixin configuration.", redeclared, method.getOutputType()); return; } // Add attribute. redeclared.addAttribute(ImplementsAttribute.KEY, ImplementsAttribute.create(method)); }