static com.kenai.jffi.Type getNativeParameterType( NativeRuntime runtime, Method m, int idx, TypeMapper typeMapper) { FromNativeConverter converter = getFromNativeConverter( m.getParameterTypes()[idx], m.getParameterAnnotations()[idx], typeMapper); Class javaClass = converter != null ? converter.nativeType() : m.getReturnType(); return jffiType( InvokerUtil.getNativeType( runtime, m.getParameterTypes()[idx], m.getParameterAnnotations()[idx])); }
protected Object[] getMemberArguments(PicoContainer container, final Method method) { return super.getMemberArguments( container, method, method.getParameterTypes(), getBindings(method.getParameterAnnotations())); }
BoundSingleParameter(final Method method, final Class<?> type, final boolean optional) { this.type = type; int pos = -1; for (int i = 0; i < method.getParameterTypes().length; ++i) { boolean pathParam = false; for (Annotation annotation : method.getParameterAnnotations()[i]) { if (annotation.annotationType().equals(PathParam.class)) { pathParam = true; break; } } if (pathParam) { continue; } if (method.getParameterTypes()[i].equals(type)) { if (pos != -1) { throw JsrWebSocketMessages.MESSAGES.moreThanOneParameterOfType(type, method); } pos = i; } } if (pos != -1) { position = pos; } else if (optional) { position = -1; } else { throw JsrWebSocketMessages.MESSAGES.parameterNotFound(type, method); } }
static ShellCommandParamSpec[] forMethod(Method theMethod) { Class[] paramTypes = theMethod.getParameterTypes(); ShellCommandParamSpec[] result = new ShellCommandParamSpec[theMethod.getParameterTypes().length]; Annotation[][] annotations = theMethod.getParameterAnnotations(); assert annotations.length == result.length; for (int i = 0; i < result.length; i++) { Param paramAnnotation = null; for (Annotation a : annotations[i]) { if (a instanceof Param) { paramAnnotation = (Param) a; break; } } if (paramAnnotation != null) { assert !paramAnnotation.name().isEmpty() : "@Param.name mustn\'t be empty"; result[i] = new ShellCommandParamSpec( paramAnnotation.name(), paramTypes[i], paramAnnotation.description(), i); } else { result[i] = new ShellCommandParamSpec(String.format("p%d", i + 1), paramTypes[i], "", i); } } return result; }
private static List<Type> parameterTypes(TypeManager typeManager, Method method) { Annotation[][] parameterAnnotations = method.getParameterAnnotations(); ImmutableList.Builder<Type> types = ImmutableList.builder(); for (int i = 0; i < method.getParameterTypes().length; i++) { Class<?> clazz = method.getParameterTypes()[i]; // skip session parameters if (clazz == ConnectorSession.class) { continue; } // find the explicit type annotation if present SqlType explicitType = null; for (Annotation annotation : parameterAnnotations[i]) { if (annotation instanceof SqlType) { explicitType = (SqlType) annotation; break; } } checkArgument( explicitType != null, "Method %s argument %s does not have a @SqlType annotation", method, i); types.add(type(typeManager, explicitType)); } return types.build(); }
@Override public void beforeActionInvocation(Method actionMethod) { try { Validation.current.set(restore()); boolean verify = false; for (Annotation[] annotations : actionMethod.getParameterAnnotations()) { if (annotations.length > 0) { verify = true; break; } } if (!verify) { return; } List<ConstraintViolation> violations = new Validator().validateAction(actionMethod); ArrayList<Error> errors = new ArrayList<Error>(); String[] paramNames = Java.parameterNames(actionMethod); for (ConstraintViolation violation : violations) { errors.add( new Error( paramNames[((MethodParameterContext) violation.getContext()).getParameterIndex()], violation.getMessage(), violation.getMessageVariables() == null ? new String[0] : violation.getMessageVariables().values().toArray(new String[0]))); } Validation.current.get().errors.addAll(errors); } catch (Exception e) { throw new UnexpectedException(e); } }
public Object[] resolveParameters( Method method, HttpServerRequest request, HttpServerResponse response, Map<String, String> pathParams, Map<String, List<String>> queryParams) throws ParamAnnotationException { Annotation[][] parametersAnnotations = method.getParameterAnnotations(); Class[] parametersTypes = method.getParameterTypes(); Object[] parameters = new Object[parametersTypes.length]; for (int i = 0; i < parametersTypes.length; i++) { Class param = parametersTypes[i]; if (param.isAssignableFrom(request.getClass())) { parameters[i] = request; } else if (param.isAssignableFrom(response.getClass())) { parameters[i] = response; } else { String value = injectParameterValueAnnotation( request, pathParams, queryParams, parametersAnnotations[i]); parameters[i] = paramTypeResolver.resolveValueType(param, value); } } return parameters; }
BoundPathParameters( final String[] positions, final Method method, Class<?> endpointClass, Set<String> paths) throws DeploymentException { this.positions = positions; this.endpointClass = endpointClass; this.paths = paths; this.encoders = new Encoding[positions.length]; this.types = new Class[positions.length]; for (int i = 0; i < positions.length; ++i) { Class type = method.getParameterTypes()[i]; Annotation[] annotations = method.getParameterAnnotations()[i]; for (int j = 0; j < annotations.length; ++j) { if (annotations[j] instanceof PathParam) { PathParam param = (PathParam) annotations[j]; if (!paths.contains(param.value())) { JsrWebSocketLogger.ROOT_LOGGER.pathTemplateNotFound( endpointClass, param, method, paths); } } } if (positions[i] == null || type == null || type == String.class) { continue; } if (EncodingFactory.DEFAULT.canEncodeText(type)) { encoders[i] = EncodingFactory.DEFAULT.createEncoding(EmptyEndpointConfig.INSTANCE); types[i] = type; } else { throw JsrWebSocketMessages.MESSAGES.couldNotFindDecoderForType(type, method); } } }
public ReflectionPostAction( String name, ActionParser parser, Object o, Method m, Class<?>... clazzes) { this.name = name; this.o = o; this.m = m; this.deprecated = m.isAnnotationPresent(Deprecated.class); Class<?>[] ps = m.getParameterTypes(); Annotation[][] as = m.getParameterAnnotations(); items = new Param[ps.length]; for (int i = 0; i < ps.length; i++) { Annotation a = null; for (int j = 0; j < as[i].length; j++) { if (as[i][j].annotationType().equals(Parameter.class)) a = as[i][j]; } if (a != null) { Parameter v = (Parameter) a; String pname = v.value(); Converter<?> converter = parser.getConverter(ps[i]); if (converter == null) throw new NullPointerException("for " + m + " parameter " + i); items[i] = new RequestParameter(pname, converter); } else { for (int j = 0; j < clazzes.length; j++) if (ps[i].equals(clazzes[j])) items[i] = new StaticParameter(j); if (ps[i].equals(HttpServletRequest.class)) items[i] = new ServletRequestParameter(); } if (items[i] == null) throw new NullPointerException("for " + m + " parameter " + i); } }
private List<WebsocketParameterDescriptor> getArguments(Method executedMethod) { List<WebsocketParameterDescriptor> descriptors = parametersCache.get(executedMethod); if (descriptors != null) { return descriptors; } Type[] parameterTypes = executedMethod.getGenericParameterTypes(); Annotation[][] allAnnotations = executedMethod.getParameterAnnotations(); descriptors = new ArrayList<>(parameterTypes.length); for (int i = 0; i < parameterTypes.length; i++) { Type type = parameterTypes[i]; String name = null; JsonPolicyDef.Policy jsonPolicy = null; for (Annotation currentParamAnnotation : allAnnotations[i]) { if (currentParamAnnotation instanceof WsParam) { name = ((WsParam) currentParamAnnotation).value(); } if (currentParamAnnotation instanceof JsonPolicyApply) { jsonPolicy = ((JsonPolicyApply) currentParamAnnotation).value(); } } descriptors.add(new WebsocketParameterDescriptor(name, type, jsonPolicy)); } parametersCache.put(executedMethod, descriptors); return descriptors; }
public void callModelValidator(final AQuery $, final Ajax ajax) throws VolleyError { Map<Annotation, java.lang.reflect.Method> methodMap = ReflectUtils.getMethodsByAnnotation(Handler.class, getClass()); for (Map.Entry<Annotation, java.lang.reflect.Method> entry : methodMap.entrySet()) { java.lang.reflect.Method method = entry.getValue(); for (int i = 0; i < method.getParameterTypes().length; i++) { Class type = method.getParameterTypes()[i]; if (method.getParameterAnnotations()[i][0] instanceof ResponseBody && type != String.class && type != byte[].class && Checker.class.isAssignableFrom(type)) { try { Checker checker = (Checker) new Gson().fromJson(new String(ajax.getResponseBody(), "utf-8"), type); if (checker.getValidator().validate()) { $.log.i("has warning"); } } catch (UnsupportedEncodingException e) { $.log.i(e); throw new IllegalDataError("Unsupported encoding bytes"); } } } } }
public static Object[] getActionMethodArgs(Method method, Object o) throws Exception { String[] paramsNames = Java.parameterNames(method); if (paramsNames == null && method.getParameterTypes().length > 0) { throw new UnexpectedException("Parameter names not found for method " + method); } // Check if we have already performed the bind operation Object[] rArgs = CachedBoundActionMethodArgs.current().retrieveActionMethodArgs(method); if (rArgs != null) { // We have already performed the binding-operation for this method // in this request. return rArgs; } rArgs = new Object[method.getParameterTypes().length]; for (int i = 0; i < method.getParameterTypes().length; i++) { Class<?> type = method.getParameterTypes()[i]; Map<String, String[]> params = new HashMap<String, String[]>(); // In case of simple params, we don't want to parse the body. if (type.equals(String.class) || Number.class.isAssignableFrom(type) || type.isPrimitive()) { params.put(paramsNames[i], Scope.Params.current().getAll(paramsNames[i])); } else { params.putAll(Scope.Params.current().all()); } Logger.trace( "getActionMethodArgs name [" + paramsNames[i] + "] annotation [" + Utils.join(method.getParameterAnnotations()[i], " ") + "]"); RootParamNode root = ParamNode.convert(params); rArgs[i] = Binder.bind( root, paramsNames[i], method.getParameterTypes()[i], method.getGenericParameterTypes()[i], method.getParameterAnnotations()[i], new Binder.MethodAndParamInfo(o, method, i + 1)); } CachedBoundActionMethodArgs.current().storeActionMethodArgs(method, rArgs); return rArgs; }
public <A extends Annotation> A getMethodParameterAnnotation( Class<A> annotation, Method method, int paramIndex, Locatable srcPos) { Annotation[] pa = method.getParameterAnnotations()[paramIndex]; for (Annotation a : pa) { if (a.annotationType() == annotation) return LocatableAnnotation.create((A) a, srcPos); } return null; }
private static PathParam getPathParam(final Method method, final int parameter) { for (final Annotation annotation : method.getParameterAnnotations()[parameter]) { if (annotation.annotationType().equals(PathParam.class)) { return (PathParam) annotation; } } return null; }
private boolean hasParamAnnotation(Method method) { Annotation[][] paramAnnotationArrays = method.getParameterAnnotations(); for (Annotation[] paramAnnotations : paramAnnotationArrays) for (Annotation paramAnnotation : paramAnnotations) if (paramAnnotation.annotationType().isAssignableFrom(Param.class)) return true; return false; }
public void init(Method method) { this.method = method; argTypes = method.getParameterTypes(); injs = new ParamInjector[argTypes.length]; Annotation[][] annss = method.getParameterAnnotations(); Type[] types = method.getGenericParameterTypes(); for (int i = 0; i < annss.length; i++) { Annotation[] anns = annss[i]; Param param = null; Attr attr = null; IocObj iocObj = null; ReqHeader reqHeader = null; // find @Param & @Attr & @IocObj in current annotations for (int x = 0; x < anns.length; x++) if (anns[x] instanceof Param) { param = (Param) anns[x]; break; } else if (anns[x] instanceof Attr) { attr = (Attr) anns[x]; break; } else if (anns[x] instanceof IocObj) { iocObj = (IocObj) anns[x]; break; } else if (anns[x] instanceof ReqHeader) { reqHeader = (ReqHeader) anns[x]; break; } // If has @Attr if (null != attr) { injs[i] = evalInjectorByAttrScope(attr); continue; } // If has @IocObj if (null != iocObj) { injs[i] = new IocObjInjector(method.getParameterTypes()[i], iocObj.value()); continue; } if (null != reqHeader) { injs[i] = new ReqHeaderInjector(reqHeader.value(), argTypes[i]); continue; } // And eval as default suport types injs[i] = evalInjectorByParamType(argTypes[i]); if (null != injs[i]) continue; // Eval by sub-classes injs[i] = evalInjector(types[i], param); // 子类也不能确定,如何适配这个参数,那么做一个标记,如果 // 这个参数被 ParamInjector 适配到,就会抛错。 // 这个设计是因为了 "路径参数" if (null == injs[i]) { injs[i] = paramNameInject(method, i); } } }
static play.mvc.Result invokeMethod( Class<?> targetClass, play.GlobalSettings global, Method method, Map<String, Object> extractedArgs, play.mvc.Http.RequestHeader r) { try { Object[] argValues = new Object[0]; List<Object> argVals = new ArrayList<Object>(); Annotation[][] annos = method.getParameterAnnotations(); for (Annotation[] ans : annos) { PathParam pathParam = null; QueryParam queryParam = null; for (Annotation an : ans) { if (an instanceof PathParam) pathParam = (PathParam) an; else if (an instanceof QueryParam) queryParam = (QueryParam) an; } if (pathParam != null) { Object v = extractedArgs.get(pathParam.value()); if (v != null) argVals.add(v); else throw new IllegalArgumentException( "can not find annotation value for argument " + pathParam.value() + "in " + targetClass + "#" + method); } else if (queryParam != null) { String queryString = r.getQueryString(queryParam.value()); argVals.add(queryString); // string type conversion? } else throw new IllegalArgumentException( "can not find an appropriate JAX-RC annotation for an argument for method:" + targetClass + "#" + method); } argValues = argVals.toArray(argValues); return (play.mvc.Result) method.invoke(global.getControllerInstance(targetClass), argValues); } catch (InvocationTargetException cause) { System.err.println( "Exception occured while trying to invoke: " + targetClass.getName() + "#" + method.getName() + " with " + extractedArgs + " for uri:" + r.path()); throw new RuntimeException(cause.getCause()); } catch (Exception e) { throw new RuntimeException(e.getCause()); } }
private String getParamNameFromAnnotation(Method method, int i, String paramName) { final Object[] paramAnnos = method.getParameterAnnotations()[i]; for (Object paramAnno : paramAnnos) { if (paramAnno instanceof Param) { paramName = ((Param) paramAnno).value(); } } return paramName; }
public boolean matchesSignature(Method method) { if (getArgumentsStackSize() != null && getArgumentsStackSize().intValue() != getArgumentsStackSize(method)) { return false; } if (getMemberName() != null && !getMemberName().toString().equals(getMethodName(method))) { return false; } if (getValueType() != null && !getValueType().matches(method.getReturnType(), annotations(method))) { return false; } Template temp = method.getAnnotation(Template.class); Annotation[][] anns = method.getParameterAnnotations(); // Class<?>[] methodArgTypes = method.getParameterTypes(); Type[] parameterTypes = method.getGenericParameterTypes(); // boolean hasThisAsFirstArgument = BridJ.hasThisAsFirstArgument(method);//methodArgTypes, // anns, true); if (paramTypes != null && !matchesArgs( parameterTypes, anns, temp == null ? 0 : temp.value().length)) // /*, hasThisAsFirstArgument*/)) { return false; } // int thisDirac = hasThisAsFirstArgument ? 1 : 0; /* switch (type) { case Constructor: case Destructor: Annotation ann = method.getAnnotation(type == SpecialName.Constructor ? Constructor.class : Destructor.class); if (ann == null) return false; if (!hasThisAsFirstArgument) return false; if (methodArgTypes.length - thisDirac != 0 ) return false; break; case InstanceMethod: if (!hasThisAsFirstArgument) return false; break; case StaticMethod: if (hasThisAsFirstArgument) return false; break; }*/ return true; }
private void bindAutoBindMethods() { for (Method method : classpathScanner.getMethods()) { if (ignoreClasses.contains(method.getDeclaringClass())) { continue; } bindParameterAnnotations(method.getParameterAnnotations()); } }
private static PojoPathParam[] getPathParams(Method m, MethodType methodType) throws DeploymentException { if (m == null) { return new PojoPathParam[0]; } boolean foundThrowable = false; Class<?>[] types = m.getParameterTypes(); Annotation[][] paramsAnnotations = m.getParameterAnnotations(); PojoPathParam[] result = new PojoPathParam[types.length]; for (int i = 0; i < types.length; i++) { Class<?> type = types[i]; if (type.equals(Session.class)) { result[i] = new PojoPathParam(type, null); } else if (methodType == MethodType.ON_OPEN && type.equals(EndpointConfig.class)) { result[i] = new PojoPathParam(type, null); } else if (methodType == MethodType.ON_ERROR && type.equals(Throwable.class)) { foundThrowable = true; result[i] = new PojoPathParam(type, null); } else if (methodType == MethodType.ON_CLOSE && type.equals(CloseReason.class)) { result[i] = new PojoPathParam(type, null); } else { Annotation[] paramAnnotations = paramsAnnotations[i]; for (Annotation paramAnnotation : paramAnnotations) { if (paramAnnotation.annotationType().equals(PathParam.class)) { // Check that the type is valid. "0" coerces to every // valid type try { Util.coerceToType(type, "0"); } catch (IllegalArgumentException iae) { throw new DeploymentException( sm.getString("pojoMethodMapping.invalidPathParamType"), iae); } result[i] = new PojoPathParam(type, ((PathParam) paramAnnotation).value()); break; } } // Parameters without annotations are not permitted if (result[i] == null) { throw new DeploymentException( sm.getString( "pojoMethodMapping.paramWithoutAnnotation", type, m.getName(), m.getClass().getName())); } } } if (methodType == MethodType.ON_ERROR && !foundThrowable) { throw new DeploymentException( sm.getString( "pojoMethodMapping.onErrorNoThrowable", m.getName(), m.getDeclaringClass().getName())); } return result; }
@Override public final Set<Descriptor> getDescriptors() { Set<Descriptor> capabilities = new HashSet<Descriptor>(); Collection<?> actions = managedObjects.values(); for (Object action : actions) { Class<?> actionClass = action.getClass(); Method[] methods = actionClass.getMethods(); for (Method method : methods) { Annotation[] declaredAnnotations = method.getDeclaredAnnotations(); boolean expose = false; for (Annotation declaredAnnotation : declaredAnnotations) { if (declaredAnnotation.annotationType() == Exposed.class) { expose = true; break; } } if (!expose) { continue; } String methodName = method.getName(); Class<?> returnType = method.getReturnType(); Class<?>[] parameterTypes = method.getParameterTypes(); List<String> parameterNames = new ArrayList<String>(); for (int i = 0; i < parameterTypes.length; i++) { Annotation[] parameterAnnotations = method.getParameterAnnotations()[i]; boolean named = false; for (Annotation parameterAnnotation : parameterAnnotations) { if (parameterAnnotation instanceof Named) { Named namedAnnotation = (Named) parameterAnnotation; parameterNames.add(namedAnnotation.value()); named = true; break; } } if (!named) { parameterNames.add("arg" + i); } } List<CallDescriptor.Parameter> parameters = new ArrayList<CallDescriptor.Parameter>(); for (int i = 0; i < parameterTypes.length; i++) { parameters.add( new CallDescriptor.Parameter(parameterNames.get(i), parameterTypes[i].getName())); } capabilities.add(new CallDescriptor(methodName, returnType.getName(), parameters)); } } return capabilities; }
static FromNativeType getParameterType( NativeRuntime runtime, Method m, int idx, TypeMapper typeMapper) { Annotation[] annotations = m.getParameterAnnotations()[idx]; Class declaredJavaClass = m.getParameterTypes()[idx]; FromNativeConverter converter = getFromNativeConverter(declaredJavaClass, annotations, typeMapper); Class javaClass = converter != null ? converter.nativeType() : declaredJavaClass; NativeType nativeType = InvokerUtil.getNativeType(runtime, javaClass, annotations); return new FromNativeType(declaredJavaClass, nativeType, annotations, converter); }
private String getParamNameFromAnnotation(int i, String paramName) { Object[] annotations = method.getParameterAnnotations()[i]; for (Object annotation : annotations) { if (annotation instanceof Param) { hasNamedParameters = true; paramName = ((Param) annotation).value(); } } return paramName; }
private boolean hasNamedParams(Method method) { final Object[][] paramAnnos = method.getParameterAnnotations(); for (Object[] paramAnno : paramAnnos) { for (Object aParamAnno : paramAnno) { if (aParamAnno instanceof Param) { return true; } } } return false; }
public PluginPoint createFrom(ServerPlugin plugin, Method method, Class<?> discovery) { ResultConverter result = ResultConverter.get(method.getGenericReturnType()); Type[] types = method.getGenericParameterTypes(); Annotation[][] annotations = method.getParameterAnnotations(); SourceExtractor sourceExtractor = null; DataExtractor[] extractors = new DataExtractor[types.length]; for (int i = 0; i < types.length; i++) { Description description = null; Parameter param = null; Source source = null; for (Annotation annotation : annotations[i]) { if (annotation instanceof Description) { description = (Description) annotation; } else if (annotation instanceof Parameter) { param = (Parameter) annotation; } else if (annotation instanceof Source) { source = (Source) annotation; } } if (param != null && source != null) { throw new IllegalStateException( String.format( "Method parameter %d of %s cannot be retrieved as both Parameter and Source", Integer.valueOf(i), method)); } else if (source != null) { if (types[i] != discovery) { throw new IllegalStateException( "Source parameter type (" + types[i] + ") must equal the discovery type (" + discovery.getName() + ")."); } if (sourceExtractor != null) { throw new IllegalStateException( "Server Extension methods may have at most one Source parameter."); } extractors[i] = sourceExtractor = new SourceExtractor(source, description); } else if (param != null) { extractors[i] = parameterExtractor(types[i], param, description); } else { throw new IllegalStateException( "Parameters of Server Extension methods must be annotated as either Source or Parameter."); } } return new PluginMethod( nameOf(method), discovery, plugin, result, method, extractors, method.getAnnotation(Description.class)); }
private boolean isSingleEntityResource(Method m) { Annotation[][] parameterAnnotations = m.getParameterAnnotations(); for (int i = 0; i < parameterAnnotations.length; i++) { for (int j = 0; j < parameterAnnotations[j].length; j++) { if (parameterAnnotations[i][j].annotationType().equals(PathParam.class)) { return true; } } } return false; }
private void parseArguments(Method method) { ImmutableSet<String> typeParameterNames = typeParameters.stream().map(TypeParameter::value).collect(toImmutableSet()); for (int i = 0; i < method.getParameterCount(); i++) { Annotation[] annotations = method.getParameterAnnotations()[i]; Class<?> parameterType = method.getParameterTypes()[i]; // Skip injected parameters if (parameterType == ConnectorSession.class) { continue; } if (containsMetaParameter(annotations)) { checkArgument( annotations.length == 1, "Meta parameters may only have a single annotation"); checkArgument(argumentTypes.isEmpty(), "Meta parameter must come before parameters"); Annotation annotation = annotations[0]; if (annotation instanceof TypeParameter) { checkArgument( typeParameters.contains(annotation), "Injected type parameters must be declared with @TypeParameter annotation on the method"); } dependencies.add(parseDependency(annotation)); } else { SqlType type = null; boolean nullableArgument = false; for (Annotation annotation : annotations) { if (annotation instanceof SqlType) { type = (SqlType) annotation; } if (annotation instanceof Nullable) { nullableArgument = true; } } requireNonNull(type, format("@SqlType annotation missing for argument to %s", method)); if (typeParameterNames.contains(type.value()) && !(parameterType == Object.class && nullableArgument)) { // Infer specialization on this type parameter. We don't do this for @Nullable Object // because it could match a type like BIGINT Class<?> specialization = specializedTypeParameters.get(type.value()); Class<?> nativeParameterType = Primitives.unwrap(parameterType); checkArgument( specialization == null || specialization.equals(nativeParameterType), "%s has conflicting specializations %s and %s", type.value(), specialization, nativeParameterType); specializedTypeParameters.put(type.value(), nativeParameterType); } argumentNativeContainerTypes.add(parameterType); argumentTypes.add(type.value()); nullableArguments.add(nullableArgument); } } }
/** * Setter projection methods may have multiple parameters. One of them may be annotated with * {@link XBValue} to select it as value to be set. * * @param method * @return index of fist parameter annotated with {@link XBValue} annotation. */ private static int findIndexOfValue(final Method method) { int index = 0; for (Annotation[] annotations : method.getParameterAnnotations()) { for (Annotation a : annotations) { if (XBValue.class.equals(a.annotationType())) { return index; } } ++index; } return 0; // If no attribute is annotated, the first one is taken. }
public void orderedSetter(Method orderedSetter) { this.orderedSetter = orderedSetter; for (Annotation a : orderedSetter.getParameterAnnotations()[0]) { if (a instanceof Digits) digits = (Digits) a; if (a instanceof Range) range = (Range) a; if (a instanceof MaxSize) maxSize = (MaxSize) a; } for (Annotation a : orderedSetter.getAnnotations()) { if (a instanceof Group) group = (Group) a; } }