Class PropertyHolder


  • public final class PropertyHolder
    extends Object

    Overview

    An instance of PropertyHolder provides runtime information for a specific BeanProperty. Under the hood it uses Beans tooling provided by the JDK and the utilities PropertyUtil an and MoreReflection. Compared to the standard tooling it is more flexible regarding fluent api style of bean / DTOs.

    Usage

    The usual entry-point is from(Class, String). In case you want to create your own instance you can use the contained builder directly using builder()

    Now you can access the metadata for that property, see getMemberInfo(), getName(), getType(), getReadMethod()

    Reading and writing of properties should be done by readFrom(Object) and writeTo(Object, Object). Directly using getReadMethod() and getWriteMethod() is more error-prone and less versatile.

    Caution:

    Use reflection only if there is no other way. Even if some of the problems are minimized by using this type. It should be used either in test-code, what we actually do, and not production code. An other reason could be framework code. as for that you should exactly know what you do.

    Author:
    Oliver Wolff