/** * Returns the {@link QueryMethod}s contained in the repository managing the given domain class. * * @param domainClass must not be {@literal null}. * @return */ public List<QueryMethod> getQueryMethodsFor(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); return getRepositoryFactoryInfoFor(domainClass).getQueryMethods(); }
/** * Returns the {@link EntityInformation} for the given domain class. * * @param domainClass must not be {@literal null}. * @return */ @SuppressWarnings("unchecked") public <T, S> EntityInformation<T, S> getEntityInformationFor(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); return (EntityInformation<T, S>) getRepositoryFactoryInfoFor(domainClass).getEntityInformation(); }
/** * Returns the {@link PersistentEntity} for the given domain class. Might return {@literal null} in case the module * storing the given domain class does not support the mapping subsystem. * * @param domainClass must not be {@literal null}. * @return the {@link PersistentEntity} for the given domain class or {@literal null} if no repository is registered * for the domain class or the repository is not backed by a {@link MappingContext} implementation. */ public PersistentEntity<?, ?> getPersistentEntity(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); return getRepositoryFactoryInfoFor(domainClass).getPersistentEntity(); }
/** * Returns the {@link RepositoryInformation} for the given domain class. * * @param domainClass must not be {@literal null}. * @return the {@link RepositoryInformation} for the given domain class or {@literal Optional#empty()} if no * repository registered for this domain class. */ public Optional<RepositoryInformation> getRepositoryInformationFor(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); RepositoryFactoryInformation<Object, Object> information = getRepositoryFactoryInfoFor(domainClass); return information == EMPTY_REPOSITORY_FACTORY_INFO ? Optional.empty() : Optional.of(information.getRepositoryInformation()); }
/** * Returns the {@link RepositoryFactoryInformation} for the given domain class. The given <code>code</code> is * converted to the actual user class if necessary, @see ProxyUtils#getUserClass. * * @param domainClass must not be {@literal null}. * @return the {@link RepositoryFactoryInformation} for the given domain class or {@literal null} if no repository * registered for this domain class. */ private RepositoryFactoryInformation<Object, Object> getRepositoryFactoryInfoFor(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); Class<?> userType = ProxyUtils.getUserClass(domainClass); RepositoryFactoryInformation<Object, Object> repositoryInfo = repositoryFactoryInfos.get(userType); if (repositoryInfo != null) { return repositoryInfo; } if (!userType.equals(Object.class)) { return getRepositoryFactoryInfoFor(userType.getSuperclass()); } return EMPTY_REPOSITORY_FACTORY_INFO; }