/** * Get the default nested property filtering conditions. * * @return default property filter */ public static PropertyFilterDefinition getDefaultFilter() { return new PropertyFilterDefinition( BeanPropertySet.NestedBeanPropertyDefinition.MAX_PROPERTY_NESTING_DEPTH, Arrays.asList("java")); } }
/** * Gets a {@link BeanPropertySet} for the given bean type. * * @param beanType * the bean type to get a property set for, not <code>null</code> * @param checkNestedDefinitions * whether to scan for nested definitions in beanType * @param filterDefinition * filtering conditions for nested properties * @return the bean property set, not <code>null</code> * @since 8.2 */ @SuppressWarnings("unchecked") public static <T> PropertySet<T> get(Class<? extends T> beanType, boolean checkNestedDefinitions, PropertyFilterDefinition filterDefinition) { Objects.requireNonNull(beanType, "Bean type cannot be null"); InstanceKey key = new InstanceKey(beanType, false, filterDefinition.getMaxNestingDepth(), filterDefinition.getIgnorePackageNamesStartingWith()); return (PropertySet<T>) INSTANCES .computeIfAbsent(key, k -> new BeanPropertySet<>(key, checkNestedDefinitions, filterDefinition)) .copy(); }
/** * Creates a new binder that uses reflection based on the provided bean type * to resolve bean properties. * * @param beanType * the bean type to use, not {@code null} * @param scanNestedDefinitions * if {@code true}, scan for nested property definitions as well * @since 8.2 */ public Binder(Class<BEAN> beanType, boolean scanNestedDefinitions) { this(BeanPropertySet.get(beanType, scanNestedDefinitions, PropertyFilterDefinition.getDefaultFilter())); }
private void findNestedDefinitions( Map<String, PropertyDefinition<T, ?>> parentDefinitions, int depth, PropertyFilterDefinition filterCallback) { if (depth >= filterCallback.getMaxNestingDepth()) { return; if (filterCallback.getIgnorePackageNamesStartingWith().stream() .anyMatch(prefix -> packageName.startsWith(prefix))) { continue;
private Object readResolve() { /* * When this instance is deserialized, it will be replaced with a * property set for the corresponding bean type and property name. */ return get(instanceKey.type, instanceKey.checkNestedDefinitions, new PropertyFilterDefinition(instanceKey.depth, instanceKey.ignorePackageNames)); } }