@Override public boolean equals(Object obj) { if (null == obj) { return false; } if (this == obj) { return true; } if (!getClass().equals(ProxyUtils.getUserClass(obj))) { return false; } AbstractPersistable<?> that = (AbstractPersistable<?>) obj; return null == this.getId() ? false : this.getId().equals(that.getId()); }
@Override protected boolean isHandler(Class<?> beanType) { Class<?> type = ProxyUtils.getUserClass(beanType); return AnnotationUtils.findAnnotation(type, RepositoryRestController.class) != null; }
@Override protected boolean isHandler(Class<?> beanType) { Class<?> type = ProxyUtils.getUserClass(beanType); return type.isAnnotationPresent(BasePathAwareController.class); }
@Override public boolean hasMappingFor(Class<?> type) { return cache.get(ProxyUtils.getUserClass(type)) != null; }
@Override public ResourceMetadata getMetadataFor(Class<?> type) { Assert.notNull(type, "Type must not be null!"); type = ProxyUtils.getUserClass(type); if (cache.containsKey(type)) { return cache.get(type); } MappingResourceMetadata metadata = getMappingMetadataFor(type); cache.put(type, metadata); return metadata; }
/** * Returns all projections registered for the given source type. * * @param sourceType must not be {@literal null}. * @return */ public Map<String, Class<?>> getProjectionsFor(Class<?> sourceType) { Assert.notNull(sourceType, "Source type must not be null!"); Class<?> userType = ProxyUtils.getUserClass(sourceType); Map<String, ProjectionDefinition> byName = new HashMap<String, ProjectionDefinition>(); Map<String, Class<?>> result = new HashMap<String, Class<?>>(); for (ProjectionDefinition entry : projectionDefinitions) { if (!entry.sourceType.isAssignableFrom(userType)) { continue; } ProjectionDefinition existing = byName.get(entry.name); if (existing == null || isSubTypeOf(entry.sourceType, existing.sourceType)) { byName.put(entry.name, entry); result.put(entry.name, entry.targetType); } } return result; }
/** * Returns the {@link MappingResourceMetadata} for the given type. * * @param type must not be {@literal null}. * @return the {@link MappingResourceMetadata} if the given type is a {@link PersistentEntity}, {@literal null} * otherwise. */ MappingResourceMetadata getMappingMetadataFor(Class<?> type) { Assert.notNull(type, "Type must not be null!"); Class<?> userType = ProxyUtils.getUserClass(type); MappingResourceMetadata mappingMetadata = mappingCache.get(userType); if (mappingMetadata != null) { return mappingMetadata; } Optional<PersistentEntity<?, ? extends PersistentProperty<?>>> entity = entities.getPersistentEntity(userType); return entity.map(it -> { MappingResourceMetadata metadata = new MappingResourceMetadata(it, this); mappingCache.put(userType, metadata); return metadata; }).orElse(null); }
@Override public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException { Class<?> beanType = ProxyUtils.getUserClass(bean); RepositoryEventHandler typeAnno = AnnotationUtils.findAnnotation(beanType, RepositoryEventHandler.class); if (typeAnno == null) { return bean; } for (Method method : ReflectionUtils.getUniqueDeclaredMethods(beanType)) { inspect(bean, method, HandleBeforeCreate.class, BeforeCreateEvent.class); inspect(bean, method, HandleAfterCreate.class, AfterCreateEvent.class); inspect(bean, method, HandleBeforeSave.class, BeforeSaveEvent.class); inspect(bean, method, HandleAfterSave.class, AfterSaveEvent.class); inspect(bean, method, HandleBeforeLinkSave.class, BeforeLinkSaveEvent.class); inspect(bean, method, HandleAfterLinkSave.class, AfterLinkSaveEvent.class); inspect(bean, method, HandleBeforeDelete.class, BeforeDeleteEvent.class); inspect(bean, method, HandleAfterDelete.class, AfterDeleteEvent.class); inspect(bean, method, HandleBeforeLinkDelete.class, BeforeLinkDeleteEvent.class); inspect(bean, method, HandleAfterLinkDelete.class, AfterLinkDeleteEvent.class); } return bean; }
@Override protected boolean isHandler(Class<?> beanType) { Class<?> type = ProxyUtils.getUserClass(beanType); return type.isAnnotationPresent(BasePathAwareController.class); }
@Override protected boolean isHandler(Class<?> beanType) { Class<?> type = ProxyUtils.getUserClass(beanType); return AnnotationUtils.findAnnotation(type, RepositoryRestController.class) != null; }
/** * Returns whether we have a repository instance registered to manage instances of the given domain class. * * @param domainClass must not be {@literal null}. * @return */ public boolean hasRepositoryFor(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); Class<?> userClass = ProxyUtils.getUserClass(domainClass); return repositoryFactoryInfos.containsKey(userClass); }
/** * Returns the repository managing the given domain class. * * @param domainClass must not be {@literal null}. * @return */ public Optional<Object> getRepositoryFor(Class<?> domainClass) { Assert.notNull(domainClass, DOMAIN_TYPE_MUST_NOT_BE_NULL); Class<?> userClass = ProxyUtils.getUserClass(domainClass); Optional<String> repositoryBeanName = Optional.ofNullable(repositoryBeanNames.get(userClass)); return beanFactory.flatMap(it -> repositoryBeanName.map(it::getBean)); }
/** * Creates {@link ClassTypeInformation} for the given type. * * @param type */ ClassTypeInformation(Class<S> type) { super(ProxyUtils.getUserClass(type), getTypeVariableMap(type)); this.type = type; }
/** * Get the actual type for the probe used. This is usually the given class, but the original class in case of a * CGLIB-generated subclass. * * @return * @see ProxyUtils#getUserClass(Class) */ @SuppressWarnings("unchecked") default Class<T> getProbeType() { return (Class<T>) ProxyUtils.getUserClass(getProbe().getClass()); } }
/** * Returns {@literal true} if the {@code type} is a supported reactive wrapper type. * * @param type must not be {@literal null}. * @return {@literal true} if the {@code type} is a supported reactive wrapper type. */ public static boolean supports(Class<?> type) { return isWrapper(ProxyUtils.getUserClass(type)); }
/** * Returns the user class for the given source object. * * @param source must not be {@literal null}. * @return */ public static Class<?> getUserClass(Object source) { Assert.notNull(source, "Source object must not be null!"); return getUserClass(AopUtils.getTargetClass(source)); }
/** * 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; }
@Override public boolean equals(Object obj) { if (null == obj) { return false; } if (this == obj) { return true; } if (!getClass().equals(ProxyUtils.getUserClass(obj))) { return false; } AbstractPersistable<?> that = (AbstractPersistable<?>) obj; return null == this.getId() ? false : this.getId().equals(that.getId()); }
Class<?> userClass = ProxyUtils.getUserClass(targetClass);