Examples of MethodParameter


Examples of org.springframework.core.MethodParameter

  @Override
  public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
      NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {

    UriComponents fromUriString = resolveBaseUri(parameter);
    MethodParameter pageableParameter = findMatchingPageableParameter(parameter);

    if (pageableParameter != null) {
      return new MethodParameterAwarePagedResourcesAssembler<Object>(pageableParameter, resolver, fromUriString);
    } else {
      return new PagedResourcesAssembler<Object>(resolver, fromUriString);
View Full Code Here

Examples of org.springframework.core.MethodParameter

      return null;
    }

    if (pageableParameters.size() == 1) {

      MethodParameter pageableParameter = pageableParameters.get(0);
      MethodParameter matchingParameter = returnIfQualifiersMatch(pageableParameter, assemblerQualifier);

      if (matchingParameter == null) {
        LOGGER.info(SUPERFLOUS_QUALIFIER, PagedResourcesAssembler.class.getSimpleName(), Pageable.class.getName());
      }

      return pageableParameter;
    }

    if (assemblerQualifier == null) {
      throw new IllegalStateException(PARAMETER_AMBIGUITY);
    }

    for (MethodParameter pageableParameter : pageableParameters) {

      MethodParameter matchingParameter = returnIfQualifiersMatch(pageableParameter, assemblerQualifier);

      if (matchingParameter != null) {
        return matchingParameter;
      }
    }
View Full Code Here

Examples of org.springframework.core.MethodParameter

    Object[] result = new Object[parameters.size()];
    Sort sortToUse = pageable == null ? sort : pageable.getSort();

    for (int i = 0; i < result.length; i++) {

      MethodParameter param = parameters.get(i);
      Class<?> targetType = param.getParameterType();

      if (Pageable.class.isAssignableFrom(targetType)) {
        result[i] = pageable;
      } else if (Sort.class.isAssignableFrom(targetType)) {
        result[i] = sortToUse;
      } else {

        String parameterName = param.getParameterName();

        if (!StringUtils.hasText(parameterName)) {
          throw new IllegalArgumentException("No @Param annotation found on query method " + method.getName()
              + " for parameter " + parameterName);
        }
View Full Code Here

Examples of org.springframework.core.MethodParameter

    List<Class<?>> types = Arrays.asList(method.getParameterTypes());

    for (int i = 0; i < types.size(); i++) {

      MethodParameter methodParameter = new MethodParameter(method, i);
      methodParameter.initParameterNameDiscovery(PARAMETER_DISCOVERER);

      T parameter = createParameter(methodParameter);

      if (parameter.isSpecialParameter() && parameter.isNamedParameter()) {
        throw new IllegalArgumentException(PARAM_ON_SPECIAL);
View Full Code Here

Examples of org.springframework.core.MethodParameter

    Class<?>[] types = baseClassMethod.getParameterTypes();

    for (int i = 0; i < genericTypes.length; i++) {

      Type type = genericTypes[i];
      MethodParameter parameter = new MethodParameter(method, i);
      Class<?> parameterType = resolveParameterType(parameter, metadata.getRepositoryInterface());

      if (type instanceof TypeVariable<?>) {
        if (!matchesGenericType((TypeVariable<?>) type, parameterType)) {
          return false;
View Full Code Here

Examples of org.springframework.core.MethodParameter

      Object result = doInvoke(invocation);

      Method method = invocation.getMethod();

      // Looking up the TypeDescriptor for the return type - yes, this way o.O
      MethodParameter parameter = new MethodParameter(method, -1);
      TypeDescriptor methodReturnTypeDescriptor = TypeDescriptor.nested(parameter, 0);

      Class<?> expectedReturnType = method.getReturnType();

      if (result != null && expectedReturnType.isInstance(result)) {
View Full Code Here

Examples of org.springframework.core.MethodParameter

  MethodParameter supportedMethodParameter;

  @Before
  public void setUp() throws Exception {
    this.supportedMethodParameter = new MethodParameter(Sample.class.getMethod("supportedMethod", Pageable.class), 0);
  }
View Full Code Here

Examples of org.springframework.core.MethodParameter

  }

  @Test
  public void qualifierIsUsedInParameterLookup() throws Exception {

    MethodParameter parameter = new MethodParameter(Sample.class.getMethod("validQualifier", Pageable.class), 0);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("foo_page", "2");
    request.addParameter("foo_size", "10");
View Full Code Here

Examples of org.springframework.core.MethodParameter

   * @see DATACMNS-377
   */
  @Test
  public void rejectsInvalidCustomDefaultForPageSize() throws Exception {

    MethodParameter parameter = new MethodParameter(Sample.class.getMethod("invalidDefaultPageSize", Pageable.class), 0);

    exception.expect(IllegalStateException.class);
    exception.expectMessage("invalidDefaultPageSize");

    assertSupportedAndResult(parameter, DEFAULT_PAGE_REQUEST);
View Full Code Here

Examples of org.springframework.core.MethodParameter

  }

  @Test
  public void rejectsNonSortParameter() {

    MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
    assertThat(getResolver().supportsParameter(parameter), is(false));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.