Class PropertyRefs
java.lang.Object
org.vaadin.firitin.util.PropertyRefs
Digs the property name out of a method reference to a getter.
Works with any serializable lambda, so also with plain Vaadin functional
interfaces like ValueProvider, not only with
PropertyRef. The JVM generates a writeReplace method for
serializable lambdas, which returns a SerializedLambda describing the
implementation method. Both javac and the Eclipse compiler produce it, so this
is not a compiler specific trick.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringpropertyName(Serializable getterReference) Resolves the property name from a method reference to a getter, e.g.static StringpropertyNameFromGetterName(String methodName) Maps a getter method name to a property name, following the JavaBeans naming convention.static SerializedLambdaserializedLambda(Serializable lambda) Returns theSerializedLambdadescribing the given serializable lambda.
-
Method Details
-
propertyName
Resolves the property name from a method reference to a getter, e.g.Person::getFirstNameresolves tofirstName.The result is cached per method reference call site, so the reflection cost is paid only once per
Foo::getBarexpression in the source code.- Parameters:
getterReference- the method reference- Returns:
- the property name
- Throws:
IllegalArgumentException- if the given lambda is not a method reference
-
serializedLambda
Returns theSerializedLambdadescribing the given serializable lambda.- Parameters:
lambda- the lambda or method reference- Returns:
- the serialized form, with e.g. the implementation method name
-
propertyNameFromGetterName
Maps a getter method name to a property name, following the JavaBeans naming convention. Names that don't look like JavaBeans getters, like record accessors, are returned as such.- Parameters:
methodName- the name of the getter method- Returns:
- the property name
-