@Override public Type getValidatedValueType(final Type type) { final ResolvedType resolvedType = resolver.resolve(type); return resolvedType.typeParametersFor(Optional.class).get(0).getErasedType(); } }
@Override public Type getValidatedValueType(final Type type) { return resolver.resolve(type) .typeParametersFor(AbstractParam.class).get(0) .getErasedType(); } }
/** * This method generates <code>ValidationCaller</code>s for each method annotated * with <code>@SelfValidation</code> that adheres to required signature. */ @SuppressWarnings({ "rawtypes" }) private <T> List<ValidationCaller> findMethods(Class<T> annotated) { ResolvedTypeWithMembers annotatedType = memberResolver.resolve(typeResolver.resolve(annotated), annotationConfiguration, null); final List<ValidationCaller> callers = Arrays.stream(annotatedType.getMemberMethods()) .filter(this::isValidationMethod) .filter(this::isMethodCorrect) .map(m -> new ProxyValidationCaller<>(annotated, m)) .collect(Collectors.toList()); if (callers.isEmpty()) { log.warn("The class {} is annotated with @SelfValidating but contains no valid methods that are annotated " + "with @SelfValidation", annotated); } return callers; }
@SuppressWarnings("WeakerAccess") public AbstractConverterDescriptor( Class<? extends AttributeConverter> converterClass, Boolean forceAutoApply, ClassmateContext classmateContext) { this.converterClass = converterClass; final ResolvedType converterType = classmateContext.getTypeResolver().resolve( converterClass ); final List<ResolvedType> converterParamTypes = converterType.typeParametersFor( AttributeConverter.class ); if ( converterParamTypes == null ) { throw new AnnotationException( "Could not extract type parameter information from AttributeConverter implementation [" + converterClass.getName() + "]" ); } else if ( converterParamTypes.size() != 2 ) { throw new AnnotationException( "Unexpected type parameter information for AttributeConverter implementation [" + converterClass.getName() + "]; expected 2 parameter types, but found " + converterParamTypes.size() ); } this.domainType = converterParamTypes.get( 0 ); this.jdbcType = converterParamTypes.get( 1 ); this.autoApplicableDescriptor = resolveAutoApplicableDescriptor( converterClass, forceAutoApply ); }
@Bean public Docket configure(SwaggerApiInfo info, TypeResolver typeResolver) { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("com.github.prontera")) .paths(PathSelectors.any()) .build() .pathMapping("/") .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.OPTIONS, info.getStatusList()) .apiInfo(new ApiInfo(info.getTitle(), DESCRIPTION, info.getVersion(), info.getServiceUrl(), new Contact(null, null, null), null, null)) .alternateTypeRules( AlternateTypeRules.newRule( typeResolver.resolve(PageInfo.class, WildcardType.class), typeResolver.resolve(SwaggerPaginationResponse.class, WildcardType.class)), AlternateTypeRules.newRule( typeResolver.resolve(Collection.class, WildcardType.class), typeResolver.resolve(List.class, WildcardType.class)) ) //.enableUrlTemplating(true) .forCodeGeneration(false); }
final ReflectionManager reflectionManager = buildingContext.getBootstrapContext().getReflectionManager(); final ResolvedType declaringClassType = classmateContext.getTypeResolver().resolve( reflectionManager.toClass( xProperty.getDeclaringClass() ) );
case SUB_RESOURCE_LOCATOR: final ResolvedType responseType = TYPE_RESOLVER .resolve(method.getInvocable().getResponseType()); final Class<?> erasedType = !responseType.getTypeBindings().isEmpty() ? responseType.getTypeBindings().getBoundType(0).getErasedType() :
@Bean public Docket swaggerSpringMvcPlugin() { return new Docket(DocumentationType.SWAGGER_2) .groupName("business-api") .select() .apis(RequestHandlerSelectors.basePackage(App.class.getPackage().getName())) .paths(PathSelectors.any()) .build() .pathMapping("/") .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules(newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) // .enableUrlTemplating(true) .useDefaultResponseMessages(true) .forCodeGeneration(false) .host(host()) .apiInfo(apiInfo()); }
ResolvedType resolvedSubType = typeResolver.resolve(subTypeMethod.getDeclaringClass()); MemberResolver memberResolver = new MemberResolver(typeResolver); memberResolver.setMethodFilter(new SimpleMethodFilter(subTypeMethod, superTypeMethod));
@Override public ResolvedType apply(ResolvedMethod input) { return Optional.fromNullable(input.getReturnType()).or(resolver.resolve(Void.TYPE)); } };
private ResolvedType returnTypeOrVoid(ResolvedMethod input) { ResolvedType returnType = input.getReturnType(); if (returnType == null) { returnType = typeResolver.resolve(Void.class); } return returnType; }
private void markIgnorablesAsHasSeen( TypeResolver typeResolver, Set<Class> ignorableParameterTypes, ModelContext modelContext) { for (Class ignorableParameterType : ignorableParameterTypes) { modelContext.seen(typeResolver.resolve(ignorableParameterType)); } }
private void addSpringMvcPassthroughTypes() { TypeResolver typeResolver = swaggerGlobalSettings.getTypeResolver(); alternateTypeProvider.addRule(newRule(typeResolver.resolve(ResponseEntity.class, WildcardType.class), typeResolver.resolve(WildcardType.class))); alternateTypeProvider.addRule(newRule(typeResolver.resolve(HttpEntity.class, WildcardType.class), typeResolver.resolve(WildcardType.class))); }
public static <T extends Collection> ResolvedType elementType(ResolvedType container, Class<T> collectionType) { List<ResolvedType> resolvedTypes = container.typeParametersFor(collectionType); if (resolvedTypes.size() == 1) { return resolvedTypes.get(0); } return new TypeResolver().resolve(Object.class); }
TypeResolver typeResolver = new TypeResolver(); MemberResolver memberResolver = new MemberResolver(typeResolver); ResolvedType type = typeResolver.resolve(ITestDouble.class); ResolvedTypeWithMembers members = memberResolver.resolve(type, null, null); ResolvedMethod[] methods = members.getMemberMethods();
@SuppressWarnings("rawtypes") private Class<?> determineAnnotationType(Class<? extends ConstraintValidator> constraintValidatorClass) { ResolvedType resolvedType = typeResolutionHelper.getTypeResolver() .resolve( constraintValidatorClass ); return resolvedType.typeParametersFor( ConstraintValidator.class ).get( 0 ).getErasedType(); }
/** * Factory method for constructing array type of given element type. */ public ResolvedArrayType arrayType(Type elementType) { ResolvedType resolvedElementType = resolve(TypeBindings.emptyBindings(), elementType); // Arrays are cumbersome for some reason: Object emptyArray = Array.newInstance(resolvedElementType.getErasedType(), 0); // Should we try to use cache? It's bit tricky, so let's not bother yet return new ResolvedArrayType(emptyArray.getClass(), TypeBindings.emptyBindings(), resolvedElementType); }
/** * Returns the sub-types binding for the single type parameter of the super-type. E.g. for {@code IntegerProperty} * and {@code Property<T>}, {@code Integer} would be returned. */ private static Class<?> getWrappedValueType(TypeResolutionHelper typeResolutionHelper, Type declaredType, ValueExtractorDescriptor valueExtractorDescriptor) { ResolvedType resolvedType = typeResolutionHelper.getTypeResolver().resolve( declaredType ); List<ResolvedType> resolvedTypeParameters = resolvedType.typeParametersFor( valueExtractorDescriptor.getContainerType() ); if ( resolvedTypeParameters == null || resolvedTypeParameters.isEmpty() ) { throw LOG.getNoValueExtractorFoundForUnwrapException( declaredType ); } return resolvedTypeParameters.get( TypeVariables.getTypeParameterIndex( valueExtractorDescriptor.getExtractedTypeParameter() ) ).getErasedType(); }