@Override public Type getParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); return (index >= types.length) ? null : types[index]; }
@Override @Deprecated // since 2.7 public Type getGenericParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return types[index]; }
@Override @Deprecated // since 2.7 public Type getGenericParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return types[index]; }
public static Type[] callGetGenericParameterTypes(Constructor thiz) { return thiz.getGenericParameterTypes(); }
public LambdaExecutable(Constructor<?> constructor) { this.parameterTypes = constructor.getGenericParameterTypes(); this.returnType = constructor.getDeclaringClass(); this.name = constructor.getName(); this.executable = constructor; }
@Override @Deprecated // since 2.7 public Type getGenericParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return types[index]; }
@Override Type[] getGenericParameterTypes() { Type[] types = constructor.getGenericParameterTypes(); if (types.length > 0 && mayNeedHiddenThis()) { Class<?>[] rawParamTypes = constructor.getParameterTypes(); if (types.length == rawParamTypes.length && rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) { // first parameter is the hidden 'this' return Arrays.copyOfRange(types, 1, types.length); } } return types; }
@Override public JavaType getParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return _typeContext.resolveType(types[index]); }
@Override public JavaType getParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return _typeContext.resolveType(types[index]); }
/** * Return the generic type of the method/constructor parameter. * * @return the parameter type (never {@code null}) */ public Type getGenericParameterType() { if (this.genericParameterType == null) { if (this.parameterIndex < 0) { this.genericParameterType = (this.method != null ? this.method.getGenericReturnType() : null); } else { this.genericParameterType = (this.method != null ? this.method.getGenericParameterTypes()[this.parameterIndex] : this.constructor.getGenericParameterTypes()[this.parameterIndex]); } } return this.genericParameterType; }
@Override Type[] getGenericParameterTypes() { Type[] types = constructor.getGenericParameterTypes(); if (types.length > 0 && mayNeedHiddenThis()) { Class<?>[] rawParamTypes = constructor.getParameterTypes(); if (types.length == rawParamTypes.length && rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) { // first parameter is the hidden 'this' return Arrays.copyOfRange(types, 1, types.length); } } return types; }
@Override public Object dispatch() throws Throwable { return ctor.newInstance(toObjects(ctor.getGenericParameterTypes())); } }
private static Type propertyTypeFromConstructor(Constructor maybeConstructor) { Type[] paramTypes = maybeConstructor.getGenericParameterTypes(); if (paramTypes.length != 1) { throw new IllegalStateException("Constructor '" + maybeConstructor.toString() + "' is annotated with @BQConfigProperty, but does not match expected signature." + " It must take exactly one parameter"); } return paramTypes[0]; }
@Override public JavaType getParameterType(int index) { Type[] types = _constructor.getGenericParameterTypes(); if (index >= types.length) { return null; } return _typeContext.resolveType(types[index]); }
@Override Type[] getGenericParameterTypes() { Type[] types = constructor.getGenericParameterTypes(); if (types.length > 0 && mayNeedHiddenThis()) { Class<?>[] rawParamTypes = constructor.getParameterTypes(); if (types.length == rawParamTypes.length && rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) { // first parameter is the hidden 'this' return Arrays.copyOfRange(types, 1, types.length); } } return types; }
public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) { LettuceAssert.notNull(constructor, "Constructor must not be null!"); Type[] types = constructor.getGenericParameterTypes(); List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(types.length); for (Type parameterType : types) { result.add(createInfo(parameterType)); } return result; }
@Override Type[] getGenericParameterTypes() { Type[] types = constructor.getGenericParameterTypes(); if (types.length > 0 && mayNeedHiddenThis()) { Class<?>[] rawParamTypes = constructor.getParameterTypes(); if (types.length == rawParamTypes.length && rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) { // first parameter is the hidden 'this' return Arrays.copyOfRange(types, 1, types.length); } } return types; }
@Override @CachedReturnPlugin.Enhance("delegate") protected Generic resolve() { java.lang.reflect.Type[] type = constructor.getGenericParameterTypes(); return erasure.length == type.length ? Sort.describe(type[index], getAnnotationReader()) : OfNonGenericType.ForLoadedType.of(erasure[index]); }
@Test public void forConstructorParameter() throws Exception { Constructor<Constructors> constructor = Constructors.class.getConstructor(List.class); ResolvableType type = ResolvableType.forConstructorParameter(constructor, 0); assertThat(type.getType(), equalTo(constructor.getGenericParameterTypes()[0])); }
private void addConstructors(Class<?> cl, EntityType type) { for (Constructor<?> constructor : cl.getConstructors()) { if (constructor.isAnnotationPresent(QueryProjection.class)) { List<Parameter> parameters = Lists.newArrayList(); for (int i = 0; i < constructor.getParameterTypes().length; i++) { Type parameterType = typeFactory.get( constructor.getParameterTypes()[i], constructor.getGenericParameterTypes()[i]); for (Annotation annotation : constructor.getParameterAnnotations()[i]) { if (annotation.annotationType().equals(QueryType.class)) { QueryType queryType = (QueryType) annotation; parameterType = parameterType.as(TypeCategory.valueOf(queryType.value().name())); } } parameters.add(new Parameter("param" + i, parameterType)); } type.addConstructor(new com.mysema.codegen.model.Constructor(parameters)); } } }