protected <X> Specification<ENTITY> equalsSpecification(Function<Root<ENTITY>, Expression<X>> metaclassFunction, final X value) {
        return (root, query, builder) -> builder.equal(metaclassFunction.apply(root), value);
    }
protected < X > Specification < ENTITY > equalsSpecification ( Function < Root < ENTITY > , Expression < X > > metaclassFunction , final X value ) { return ( root , query , builder ) -> builder . equal ( metaclassFunction . apply ( root ) , value ) ; }
Generic method, which based on a Root&lt;ENTITY&gt; returns an Expression which type is the same as the given 'value' type.

@param metaclassFunction function which returns the column which is used for filtering.
@param value             the actual value to filter for.
@param <X>              The type of the attribute which is filtered.
@return a Specification.