public ValidatorBean(BeanManager beanManager, Bean<?> validatorFactoryBean, ValidationProviderHelper validationProviderHelper) { this.beanManager = beanManager; this.validatorFactoryBean = validatorFactoryBean; this.validationProviderHelper = validationProviderHelper; this.types = Collections.unmodifiableSet( CollectionHelper.<Type>newHashSet( ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorBeanClass() ) ) ); }
public ValidatorFactoryBean(BeanManager beanManager, ValidationProviderHelper validationProviderHelper) { this.beanManager = beanManager; this.destructibleResources = newHashSet( 5 ); this.validationProviderHelper = validationProviderHelper; this.types = Collections.unmodifiableSet( CollectionHelper.<Type>newHashSet( ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorFactoryBeanClass() ) ) ); }
/** * Get a list of all methods which the given class declares, implements, * overrides or inherits. Methods are added by adding first all methods of * the class itself and its implemented interfaces, then the super class and * its interfaces, etc. * * @param clazz the class for which to retrieve the methods * * @return set of all methods of the given class */ public static List<Method> getAllMethods(Class<?> clazz) { Contracts.assertNotNull( clazz ); List<Method> methods = newArrayList(); for ( Class<?> hierarchyClass : ClassHierarchyHelper.getHierarchy( clazz ) ) { Collections.addAll( methods, run( GetMethods.action( hierarchyClass ) ) ); } return methods; }
@Override public <T> List<BeanConfiguration<? super T>> getBeanConfigurationForHierarchy(Class<T> beanClass) { List<BeanConfiguration<? super T>> configurations = newArrayList(); for ( Class<? super T> clazz : ClassHierarchyHelper.getHierarchy( beanClass ) ) { BeanConfiguration<? super T> configuration = getBeanConfiguration( clazz ); if ( configuration != null ) { configurations.add( configuration ); } } return configurations; }
/** * Retrieves all superclasses and interfaces recursively. * * @param clazz the class to start the search with * @param classes list of classes to which to add all found super types matching * the given filters * @param filters filters applying for the search */ private static <T> void getHierarchy(Class<? super T> clazz, List<Class<? super T>> classes, Iterable<Filter> filters) { for ( Class<? super T> current = clazz; current != null; current = current.getSuperclass() ) { if ( classes.contains( current ) ) { return; } if ( acceptedByAllFilters( current, filters ) ) { classes.add( current ); } for ( Class<?> currentInterface : current.getInterfaces() ) { //safe since interfaces are super-types @SuppressWarnings("unchecked") Class<? super T> currentInterfaceCasted = (Class<? super T>) currentInterface; getHierarchy( currentInterfaceCasted, classes, filters ); } } }
@Override public <T> List<BeanConfiguration<? super T>> getBeanConfigurationForHierarchy(Class<T> beanClass) { List<BeanConfiguration<? super T>> configurations = newArrayList(); for ( Class<? super T> hierarchyClass : ClassHierarchyHelper.getHierarchy( beanClass ) ) { BeanConfiguration<? super T> configuration = getBeanConfiguration( hierarchyClass ); if ( configuration != null ) { configurations.add( configuration ); } } return configurations; }
public ValidatorBean(BeanManager beanManager, Bean<?> validatorFactoryBean, ValidationProviderHelper validationProviderHelper) { this.beanManager = beanManager; this.validatorFactoryBean = validatorFactoryBean; this.validationProviderHelper = validationProviderHelper; this.types = Collections.unmodifiableSet( CollectionHelper.<Type>newHashSet( ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorBeanClass() ) ) ); }
/** * Retrieves all superclasses and interfaces recursively. * * @param clazz the class to start the search with * @param classes list of classes to which to add all found super types matching * the given filters * @param filters filters applying for the search */ private static <T> void getHierarchy(Class<? super T> clazz, List<Class<? super T>> classes, Iterable<Filter> filters) { for ( Class<? super T> current = clazz; current != null; current = current.getSuperclass() ) { if ( classes.contains( current ) ) { return; } if ( acceptedByAllFilters( current, filters ) ) { classes.add( current ); } for ( Class<?> currentInterface : current.getInterfaces() ) { //safe since interfaces are super-types @SuppressWarnings("unchecked") Class<? super T> currentInterfaceCasted = (Class<? super T>) currentInterface; getHierarchy( currentInterfaceCasted, classes, filters ); } } }
/** * Returns a list with the configurations for all types contained in the given type's hierarchy (including * implemented interfaces) starting at the specified type. * * @param beanClass The type of interest. * @param <T> The type of the class to get the configurations for. * @return A set with the configurations for the complete hierarchy of the given type. May be empty, but never * {@code null}. */ private <T> List<BeanConfiguration<? super T>> getBeanConfigurationForHierarchy(MetaDataProvider provider, Class<T> beanClass) { List<BeanConfiguration<? super T>> configurations = newArrayList(); for ( Class<? super T> clazz : ClassHierarchyHelper.getHierarchy( beanClass ) ) { BeanConfiguration<? super T> configuration = provider.getBeanConfiguration( clazz ); if ( configuration != null ) { configurations.add( configuration ); } } return configurations; } }
public ValidatorFactoryBean(BeanManager beanManager, ValidationProviderHelper validationProviderHelper) { this.beanManager = beanManager; this.destructibleResources = newHashSet( 5 ); this.validationProviderHelper = validationProviderHelper; this.types = Collections.unmodifiableSet( CollectionHelper.<Type>newHashSet( ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorFactoryBeanClass() ) ) ); }
/** * Gets the elements of the hierarchy of the given class which match the * given filters. Classes are added by starting with the class itself and * its implemented interfaces. Then its super class and interfaces are added * and so on. * * @param clazz the class for which to retrieve the hierarchy * @param filters filters applying for the search * @param <T> the type of the class * * @return List of hierarchy classes. Will only contain those types matching * the given filters. The list contains the given class itself, if * it is no proxy class. */ public static <T> List<Class<? super T>> getHierarchy(Class<T> clazz, Filter... filters) { Contracts.assertNotNull( clazz ); List<Class<? super T>> classes = newArrayList(); List<Filter> allFilters = newArrayList(); allFilters.addAll( Arrays.asList( filters ) ); allFilters.add( Filters.excludeProxies() ); getHierarchy( clazz, classes, allFilters ); return classes; }
/** * Gets the elements of the hierarchy of the given class which match the * given filters. Classes are added by starting with the class itself and * its implemented interfaces. Then its super class and interfaces are added * and so on. * * @param clazz the class for which to retrieve the hierarchy * @param filters filters applying for the search * @param <T> the type of the class * * @return List of hierarchy classes. Will only contain those types matching * the given filters. The list contains the given class itself, if * it is no proxy class. */ public static <T> List<Class<? super T>> getHierarchy(Class<T> clazz, Filter... filters) { Contracts.assertNotNull( clazz ); List<Class<? super T>> classes = newArrayList(); List<Filter> allFilters = newArrayList(); allFilters.addAll( Arrays.asList( filters ) ); allFilters.add( Filters.excludeProxies() ); getHierarchy( clazz, classes, allFilters ); return classes; }
/** * Get a list of all methods which the given class declares, implements, * overrides or inherits. Methods are added by adding first all methods of * the class itself and its implemented interfaces, then the super class and * its interfaces, etc. * * @param clazz the class for which to retrieve the methods * * @return set of all methods of the given class */ public static List<Method> getAllMethods(Class<?> clazz) { Contracts.assertNotNull( clazz ); List<Method> methods = newArrayList(); for ( Class<?> hierarchyClass : ClassHierarchyHelper.getHierarchy( clazz ) ) { Collections.addAll( methods, run( GetMethods.action( hierarchyClass ) ) ); } return methods; }
this.allMetaConstraints = Collections.unmodifiableSet( allMetaConstraints ); this.classHierarchyWithoutInterfaces = ClassHierarchyHelper.getHierarchy( beanClass, Filters.excludeInterfaces()
this.allMetaConstraints = CollectionHelper.toImmutableSet( allMetaConstraints ); this.classHierarchyWithoutInterfaces = CollectionHelper.toImmutableList( ClassHierarchyHelper.getHierarchy( beanClass, Filters.excludeInterfaces()