Class BasicBeanConverter.Builder
- Enclosing class:
- BasicBeanConverter
This builder provides a fluent API for configuring custom type handlers, settings, and property extraction logic. The builder supports registration of four main types of customizations:
Type Handlers:
- addStringifier(Class, Stringifier)- Custom string conversion logic
- addListifier(Class, Listifier)- Custom list conversion for collection-like objects
- addSwapper(Class, Swapper)- Pre-processing and object transformation
- addPropertyExtractor(PropertyExtractor)- Custom property access strategies
PropertyExtractors:
Property extractors define how the converter accesses object properties during nested
 field access (e.g., "user.address.city"). The converter uses a chain-of-responsibility
 pattern, trying each registered extractor until one succeeds:
- PropertyExtractors.ObjectPropertyExtractor- JavaBean-style properties via reflection
- PropertyExtractors.ListPropertyExtractor- Numeric indices and size/length for arrays/collections
- PropertyExtractors.MapPropertyExtractor- Key-based access for Map objects
Custom extractors can be added to handle specialized property access patterns:
    
Default Configuration:
The defaultSettings() method pre-registers comprehensive type handlers
 and property extractors for common Java types, providing out-of-the-box functionality
 for most use cases while still allowing full customization.
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddListifier(Class<T> c, Listifier<T> l) Registers a custom listifier for a specific type.Registers a custom property extractor for specialized property access logic.addSetting(String key, Object value) Adds a configuration setting to the converter.addStringifier(Class<T> c, Stringifier<T> s) Registers a custom stringifier for a specific type.addSwapper(Class<T> c, Swapper<T> s) Registers a custom swapper for a specific type.build()Builds the configured BasicBeanConverter instance.Adds default handlers and settings for common Java types.
- 
Constructor Details- 
Builderpublic Builder()
 
- 
- 
Method Details- 
addSettingAdds a configuration setting to the converter.- Parameters:
- key- The setting key (use SETTING_* constants)
- value- The setting value
- Returns:
- This builder for method chaining
 
- 
addStringifierRegisters a custom stringifier for a specific type.Stringifiers convert objects to their string representations. The BiFunction receives the object to convert and the converter instance for recursive calls. - Type Parameters:
- T- The type to handle
- Parameters:
- c- The class to register the stringifier for
- s- The stringification function
- Returns:
- This builder for method chaining
 
- 
addListifierRegisters a custom listifier for a specific type.Listifiers convert collection-like objects to List<Object>. The BiFunction receives the object to convert and the converter instance for recursive calls. - Type Parameters:
- T- The type to handle
- Parameters:
- c- The class to register the listifier for
- l- The listification function
- Returns:
- This builder for method chaining
 
- 
addSwapperRegisters a custom swapper for a specific type.Swappers pre-process objects before conversion. Common uses include unwrapping Optional values, calling Supplier methods, or extracting values from wrapper objects. - Type Parameters:
- T- The type to handle
- Parameters:
- c- The class to register the swapper for
- s- The swapping function
- Returns:
- This builder for method chaining
 
- 
addPropertyExtractorRegisters a custom property extractor for specialized property access logic.Property extractors enable custom property access patterns beyond standard JavaBean conventions. The converter tries extractors in registration order until one returns a non- null value. This allows for:- Custom data structures: Special property access for non-standard objects
- Database entities: Property access via entity-specific methods
- Dynamic properties: Computed or cached property values
- Legacy objects: Bridging older APIs with modern property access
 Implementation Example:// Custom extractor for a specialized data class PropertyExtractorcustomExtractor = (obj ,property ) -> {if (obj instanceof DatabaseEntityentity ) {switch (property ) {case "id" :return entity .getPrimaryKey();case "displayName" :return entity .computeDisplayName();case "metadata" :return entity .getMetadataAsMap(); } }return null ;// Let next extractor try };var converter = BasicBeanConverter.builder () .addPropertyExtractor(customExtractor ) .defaultSettings()// Adds standard extractors .build();Execution Order: Custom extractors are tried before the default extractors added by defaultSettings(), allowing overrides of standard behavior.- Parameters:
- e- The property extractor to register
- Returns:
- This builder for method chaining
- See Also:
 
- 
defaultSettingsAdds default handlers and settings for common Java types.This method registers comprehensive support for: - Collections: List, Set, Collection → bracket format
- Maps: Map, Properties → brace format with key=value pairs
- Map Entries: Map.Entry → "key=value" format
- Dates: Date, Calendar → ISO-8601 format
- Files/Streams: File, InputStream, Reader → content extraction
- Reflection: Class, Method, Constructor → readable signatures
- Enums: All enum types → name() format
- Iterables: Iterable, Iterator, Enumeration, Stream → list conversion
- Wrappers: Optional, Supplier → unwrapping/evaluation
 Default settings include: - nullValue=- "<null>" 
- emptyValue=- "<empty>" 
- classNameFormat=- "simple" 
 Note: This should typically be called after custom handlers to avoid overriding your custom configurations, since handlers are processed in reverse order. - Returns:
- This builder for method chaining
 
- 
buildBuilds the configured BasicBeanConverter instance.This method creates a new BasicBeanConverter with all registered handlers and settings. The builder can be reused to create multiple converters with the same configuration. - Returns:
- A new BasicBeanConverter instance
 
 
-