Class PropertyExtractors.ListPropertyExtractor
- All Implemented Interfaces:
PropertyExtractor
- Enclosing class:
- PropertyExtractors
This extractor extends PropertyExtractors.ObjectPropertyExtractor to add special handling for
collection-like objects. It provides array-style access using numeric indices and
universal size/length properties for any listifiable object.
Additional Properties:
- Numeric indices:
"0" ,"1" ,"2" , etc. for element access - Negative indices:
"-1" ,"-2" for reverse indexing (from end) - Size properties:
"length" and"size" return collection size
Supported Types:
Works with any object that can be listified by the converter:
- Arrays: All array types (primitive and object)
- Collections: List, Set, Queue, and all Collection subtypes
- Iterables: Any object implementing Iterable
- Streams: Stream objects and other lazy sequences
- Maps: Converted to list of entries for iteration
Examples:
Fallback: If the property is not a numeric index or size property,
delegates to PropertyExtractors.ObjectPropertyExtractor for standard property access.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanExtract(BeanConverter converter, Object o, String name) Determines if this extractor can handle property access for the given object and property name.extract(BeanConverter converter, Object o, String name) Extracts the specified property value from the given object.
-
Constructor Details
-
ListPropertyExtractor
public ListPropertyExtractor()
-
-
Method Details
-
canExtract
Description copied from interface:PropertyExtractorDetermines if this extractor can handle property access for the given object and property name.This method should perform a quick check to determine compatibility without doing expensive operations. It's called frequently during property navigation.
- Specified by:
canExtractin interfacePropertyExtractor- Overrides:
canExtractin classPropertyExtractors.ObjectPropertyExtractor- Parameters:
converter- The bean converter instance (for recursive operations if needed)o- The object to extract the property fromname- The property name to extract- Returns:
trueif this extractor can handle the property access,falseotherwise
-
extract
Description copied from interface:PropertyExtractorExtracts the specified property value from the given object.This method is only called after
PropertyExtractor.canExtract(BeanConverter, Object, String)returnstrue. It should perform the actual property extraction and return the property value.- Specified by:
extractin interfacePropertyExtractor- Overrides:
extractin classPropertyExtractors.ObjectPropertyExtractor- Parameters:
converter- The bean converter instance (for recursive operations if needed)o- The object to extract the property fromname- The property name to extract- Returns:
- The property value
-