Package com.google.common.reflect

Examples of com.google.common.reflect.Parameter


      Collection<Parameter> endpointParams = parametersWithAnnotation(invocation.getInvokable(), EndpointParam.class);
      if (endpointParams.isEmpty())
         return null;
      checkState(endpointParams.size() == 1, "invocation.getInvoked() %s has too many EndpointParam annotations",
            invocation.getInvokable());
      Parameter endpointParam = get(endpointParams, 0);
      Function<Object, URI> parser = injector.getInstance(endpointParam.getAnnotation(EndpointParam.class).parser());
      int position = endpointParam.hashCode();// guava issue 1243
      try {
         URI returnVal = parser.apply(invocation.getArgs().get(position));
         checkArgument(returnVal != null,
               format("endpoint for [%s] not configured for %s", position, invocation.getInvokable()));
         return returnVal;
View Full Code Here


      Collection<Parameter> endpointParams = parametersWithAnnotation(invocation.getInvokable(), EndpointParam.class);
      if (endpointParams.isEmpty())
         return null;
      checkState(endpointParams.size() == 1, "invocation.getInvoked() %s has too many EndpointParam annotations",
            invocation.getInvokable());
      Parameter endpointParam = get(endpointParams, 0);
      Function<Object, URI> parser = injector.getInstance(endpointParam.getAnnotation(EndpointParam.class).parser());
      int position = endpointParam.hashCode();// guava issue 1243
      try {
         URI returnVal = parser.apply(invocation.getArgs().get(position));
         checkArgument(returnVal != null,
               format("endpoint for [%s] not configured for %s", position, invocation.getInvokable()));
         return returnVal;
View Full Code Here

    }

    private boolean typesMatch(List<? extends VariableElement> parameters, ImmutableList<Parameter> invokableParameters) {
        for (int i = 0; i < parameters.size(); i++) {
            final VariableElement left = parameters.get(i);
            final Parameter right = invokableParameters.get(i);

            final boolean typesMatch = left.asType().toString().equals(right.getClass().getName());

            if (typesMatch) {
                continue;
            }
View Full Code Here

    @Override protected Object handleInvocation(
        Object proxy, Method method, Object[] args) {
      Invokable<?, ?> invokable = interfaceType.method(method);
      ImmutableList<Parameter> params = invokable.getParameters();
      for (int i = 0; i < args.length; i++) {
        Parameter param = params.get(i);
        if (!param.isAnnotationPresent(Nullable.class)) {
          checkNotNull(args[i]);
        }
      }
      return dummyReturnValue(interfaceType.resolveType(method.getGenericReturnType()));
    }
View Full Code Here

  private Object[] buildParamList(Invokable<?, ?> invokable, int indexOfParamToSetToNull) {
    ImmutableList<Parameter> params = invokable.getParameters();
    Object[] args = new Object[params.size()];

    for (int i = 0; i < args.length; i++) {
      Parameter param = params.get(i);
      if (i != indexOfParamToSetToNull) {
        args[i] = getDefaultValue(param.getType());
        Assert.assertTrue(
            "Can't find or create a sample instance for type '"
                + param.getType()
                + "'; please provide one using NullPointerTester.setDefault()",
            args[i] != null || isNullable(param));
      }
    }
    return args;
View Full Code Here

      Invokable<?, ?> factory, List<Parameter> params, List<Object> args)
      throws ParameterNotInstantiableException, FactoryMethodReturnsNullException,
      InvocationTargetException, IllegalAccessException {
    List<Object> equalArgs = Lists.newArrayList(args);
    for (int i = 0; i < args.size(); i++) {
      Parameter param = params.get(i);
      Object arg = args.get(i);
      // Use new fresh value generator because 'args' were populated with new fresh generator each.
      // Two newFreshValueGenerator() instances should normally generate equal value sequence.
      Object shouldBeEqualArg = generateDummyArg(param, newFreshValueGenerator());
      if (arg != shouldBeEqualArg
View Full Code Here

      Collection<Parameter> endpointParams = parametersWithAnnotation(invocation.getInvokable(), EndpointParam.class);
      if (endpointParams.isEmpty())
         return null;
      checkState(endpointParams.size() == 1, "invocation.getInvoked() %s has too many EndpointParam annotations",
            invocation.getInvokable());
      Parameter endpointParam = get(endpointParams, 0);
      Function<Object, URI> parser = injector.getInstance(endpointParam.getAnnotation(EndpointParam.class).parser());
      int position = endpointParam.hashCode();// guava issue 1243
      try {
         URI returnVal = parser.apply(invocation.getArgs().get(position));
         checkArgument(returnVal != null,
               format("endpoint for [%s] not configured for %s", position, invocation.getInvokable()));
         return returnVal;
View Full Code Here

      Collection<Parameter> endpointParams = parametersWithAnnotation(invocation.getInvokable(), EndpointParam.class);
      if (endpointParams.isEmpty())
         return null;
      checkState(endpointParams.size() == 1, "invocation.getInvoked() %s has too many EndpointParam annotations",
            invocation.getInvokable());
      Parameter endpointParam = get(endpointParams, 0);
      Function<Object, URI> parser = injector.getInstance(endpointParam.getAnnotation(EndpointParam.class).parser());
      int position = endpointParam.hashCode();// guava issue 1243
      try {
         URI returnVal = parser.apply(invocation.getArgs().get(position));
         checkArgument(returnVal != null,
               format("endpoint for [%s] not configured for %s", position, invocation.getInvokable()));
         return returnVal;
View Full Code Here

                if (!NOT_NULL_VALIDATOR.isValid(arg, null)) {

                    // JSR 303 doesn't support method level validation
                    // we should provide at least a dummy implementation to detect @NotNull annotations
                    // we should migrate our implementation to bean validation 1.1 when possible
                    final Parameter parameter = invokable.getParameters().get(i);
                    final NotNull annotation = parameter.getAnnotation(NotNull.class);
                    if (annotation != null) {

                        final String parameterName = "arg" + i;
                        final ConstraintDescriptor<NotNull> descriptor = new SimpleConstraintDescriptor<NotNull>(
                                annotation, ImmutableSet.<Class<?>>of(Default.class),
View Full Code Here

      Collection<Parameter> endpointParams = parametersWithAnnotation(invocation.getInvokable(), EndpointParam.class);
      if (endpointParams.isEmpty())
         return null;
      checkState(endpointParams.size() == 1, "invocation.getInvoked() %s has too many EndpointParam annotations",
            invocation.getInvokable());
      Parameter endpointParam = get(endpointParams, 0);
      Function<Object, URI> parser = injector.getInstance(endpointParam.getAnnotation(EndpointParam.class).parser());
      int position = endpointParam.hashCode();// guava issue 1243
      try {
         URI returnVal = parser.apply(invocation.getArgs().get(position));
         checkArgument(returnVal != null,
               format("endpoint for [%s] not configured for %s", position, invocation.getInvokable()));
         return returnVal;
View Full Code Here

TOP

Related Classes of com.google.common.reflect.Parameter

Copyright © 2018 www.massapicom. 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.