My question is pretty much in the title. I would like to create an interface and then initialize it with a definition of the methods right then and there. Anyone familiar with Java would recognize this style of code.
If anyone wants use case, A Filter interface with a method filterOut. Another class has a method that takes a list of sobjects and an object of type Filter and returns only the items that match the conditions layed out in that Filter's filterOut method. Rather than create a pile of named inner or outter classes, it woubl be nice to just go:
filterList(listOfObjects, new Filter{
Boolean filterOut(SObject obj){
return obj.name == 'Bob';
}
}
Can anyone tell me if this is possible?