private <C extends UserPasswordConfiguration<C>, T extends ConfigurationProperty<C>> void cleanupType(PropertyType<T> propertyType, String configurationName) { //noinspection unchecked propertyService // Looks for all entities which have a property pointing to this configuration .searchWithPropertyValue( (Class<? extends PropertyType<T>>) propertyType.getClass(), (entityType, id) -> entityType.getEntityFn(structureService).apply(id), property -> StringUtils.equals(property.getConfiguration().getName(), configurationName) ) // Deleting this property .forEach(projectEntity -> propertyService.deleteProperty(projectEntity, propertyType.getTypeName())); } }