- Type Parameters:
T
- The generic base type.
- All Superinterfaces:
Function<T,
,Object> Serializable
So we can extract method info from a method reference. Usage example:
Map<Getter<YourEntity>, Object> criteria = new HashMap<>(); criteria.put(YourEntity::getName, Like.startsWith(searchNameStartsWith)); criteria.put(YourEntity::getCreated, Order.greaterThanOrEqualTo(searchStartDate)); criteria.put(YourEntity::getType, searchTypes); criteria.put(YourEntity::isDeleted, false);
And then later on in "the backend":
criteria.forEach((getter, value) -> requiredCriteria.put(getter.getPropertyName(), value));
This allows a type safe way of defining property names.
Inspired by Lambda parameter names with reflection. NOTE: works only in Java 8u60 and newer.
- Author:
- Bauke Scholtz
-
Method Summary
Modifier and TypeMethodDescriptiondefault Method
default String
default Class<?>
default SerializedLambda
-
Method Details
-
getSerializedLambda
-
getBaseType
-
getMethod
-
getPropertyName
-
getReturnType
-