@SuppressWarnings("unchecked") QueryPostProcessorMetadata(@NonNull QueryPostProcessor<?, ?> queryPostProcessor) { Assert.notNull(queryPostProcessor, "QueryPostProcessor must not be null"); this.queryPostProcessor = queryPostProcessor; List<TypeInformation<?>> typeArguments = ClassTypeInformation.from(queryPostProcessor.getClass()) .getRequiredSuperTypeInformation(QueryPostProcessor.class) .getTypeArguments(); this.declaredRepositoryType = Optional.of(typeArguments) .filter(list -> !list.isEmpty()) .map(list -> list.get(0)) .map(typeInfo -> typeInfo.getType()) .orElse((Class) Repository.class); }
@SuppressWarnings("unchecked") QueryPostProcessorMetadata(@NonNull QueryPostProcessor<?, ?> queryPostProcessor) { Assert.notNull(queryPostProcessor, "QueryPostProcessor must not be null"); this.queryPostProcessor = queryPostProcessor; List<TypeInformation<?>> typeArguments = ClassTypeInformation.from(queryPostProcessor.getClass()) .getRequiredSuperTypeInformation(QueryPostProcessor.class) .getTypeArguments(); this.declaredRepositoryType = Optional.of(typeArguments) .filter(list -> !list.isEmpty()) .map(list -> list.get(0)) .map(typeInfo -> typeInfo.getType()) .orElse((Class) Repository.class); }
/** * Creates a new {@link DefaultRepositoryMetadata} for the given repository interface. * * @param repositoryInterface must not be {@literal null}. */ public DefaultRepositoryMetadata(Class<?> repositoryInterface) { super(repositoryInterface); Assert.isTrue(Repository.class.isAssignableFrom(repositoryInterface), MUST_BE_A_REPOSITORY); List<TypeInformation<?>> arguments = ClassTypeInformation.from(repositoryInterface) // .getRequiredSuperTypeInformation(Repository.class)// .getTypeArguments(); this.domainType = resolveTypeParameter(arguments, 0, () -> String.format("Could not resolve domain type of %s!", repositoryInterface)); this.idType = resolveTypeParameter(arguments, 1, () -> String.format("Could not resolve id type of %s!", repositoryInterface)); }