So how are Native Queries realized in practice?
Let's return to the Pilot class. Suppose we need to find all pilots with the name starting from "M" and points over 100. In a native OO language it would be expressed as:
Java:
pilot.getName().startsWith("M")
&& pilot.getPoints() > 100
Java:
public abstract class
Predicate <ExtentType> {
public <ExtentType> Predicate (){}
public abstract boolean match (ExtentType candidate);
}
new Predicate <Pilot>
() {
public boolean match(Pilot pilot){
return
pilot.getName().contains("M") && pilot.getPoints() > 100;
}
}
For more information about NQ implementations in the other Java and .NET versions see Native Query Syntax.