How can I use something like this (Lambda Expression) in Java with JDK7 ?
public virtual IEnumerable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null)
I am trying to pass this method a where clause to filter the select statement, in C# I can use Lambda expressions and I am searching for a solution to do this in my Java project.
public List<TEntity> Get() {
List<TEntity> result = emf.createEntityManager().createNamedQuery(ClassName + ".findAll").getResultList();
return result;
}
This is my Method and i would like to pass a where clause tot this method.
I’m not a C(sharp) person, but isn’t that just the equivalent of:
Follow up to your edit: I don’t know the .NET library, but a filtering in Java would look something like:
In the current verbose syntax that would called like:
A more concise syntax with random changes to semantics should be added in Java SE 8, along with library additions.