public List<Method> getMethods(final String methodPath) { final List<Method> result = new ArrayList<>(); for (final Method method : getMethods()) { if (methodPath.equals(method.getPath())) { result.add(method); } } return Collections.unmodifiableList(result); }
public List<Method> getMethods(final MethodType type) { final List<Method> result = new ArrayList<>(); for (final Method method : getMethods()) { if (type.equals(method.getMethodType())) { result.add(method); } } return Collections.unmodifiableList(result); }
private void validatePatchMethod(final Resource target) { final List<Method> patchMethods = target.getMethods(MethodType.PATCH); for (final Method patchMethod : patchMethods) { if (!hasCorrespondingResponse(target.getMethods(MethodType.GET), patchMethod) && patchMethod.getConsumes().contains(MediaType.JSON_PATCH.getCode())) { throw new ModelValidationException( "The corresponding GET method for the following PATCH method is missing: " + patchMethod.getQualifier() + ", or it does not contain responses returning media types " + patchMethod.getProduces() + " and matching schemas"); } } }
@Override public Map<ActionType, Action> resolve(final Resource resource) { final ImmutableMap.Builder<ActionType, Action> actions = ImmutableMap.builder(); for (final Method m : resource.getMethods()) { final Action action = new Action(); action.setDescription(m.getDescription()); action.setBody(bodyParamResolver.resolve(m)); action.setQueryParameters(queryParamsResolver.resolve(getParametersFor(m.getParameters(), ParameterType.QUERY))); action.setHeaders(headerParamsResolver.resolve(getParametersFor(m.getParameters(), ParameterType.HEADER))); // action.setResource(); action.setResponses(responseResolver.resolve(m)); actions.put(getActionType(m.getMethodType()), action); } return actions.build(); }