Package org.bremersee.comparator
Class DefaultValueExtractor
- java.lang.Object
-
- org.bremersee.comparator.DefaultValueExtractor
-
- All Implemented Interfaces:
ValueExtractor
public class DefaultValueExtractor extends Object implements ValueExtractor
The default value extractor supports field names and paths as described inComparatorField. A field name can be just the field name (e. g.firstName), a method name, that is not generated byValueExtractor.getPossibleMethodNames(String)(e. g.toString) or a path of field names separated by dots (.), e. g.person.firstName.- Author:
- Christian Bremer
-
-
Constructor Summary
Constructors Constructor Description DefaultValueExtractor()Instantiates a new default value extractor that will throwValueExtractorException, if the given field cannot be found.DefaultValueExtractor(boolean throwingException)Instantiates a new default value extractor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectfindValue(Object obj, String fieldPath)Find the value of the given add name or path of the given object.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bremersee.comparator.ValueExtractor
findField, findField, findMethod, findMethod, getPossibleMethodNames, invoke, invoke
-
-
-
-
Constructor Detail
-
DefaultValueExtractor
public DefaultValueExtractor()
Instantiates a new default value extractor that will throwValueExtractorException, if the given field cannot be found.
-
DefaultValueExtractor
public DefaultValueExtractor(boolean throwingException)
Instantiates a new default value extractor.- Parameters:
throwingException- iftrueand the given field cannot be found,ValueExtractorExceptionwill be thrown; otherwisenullwill be returned
-
-
Method Detail
-
findValue
public Object findValue(Object obj, String fieldPath)
Description copied from interface:ValueExtractorFind the value of the given add name or path of the given object.- Specified by:
findValuein interfaceValueExtractor- Parameters:
obj- the objectfieldPath- the field name or path- Returns:
- the object
-
-