Here's something we could write with a Java API:
// Java 5, with Iterable interface for the foreach loop
explorer.find(new ClassFinder() {
public boolean classMatches(QueryClass aClass) {
for (QueryMethod aMethod: aClass.getMethods()) {
if (aMethod.isLike("join") && aMethod.isReturning("net.jxta.credential.Credential"))
return true;
}
return false;
}
});
And here are some possible variations of a DSL syntax for the same querying system:
def explorer = new Explorer() // pass it some jar file paths
explorer.query(
select: classes,
where: extend("net.jxta.service.Service"),
and: hasMethod(
like: "join",
returning: "net.jxta.credential.Credential"
)
}
explorer.findAllClasses { aClass ->
aClass.isExtending("net.jxta.service.Service") &&
aClass.hasMethod { aMethod ->
aMethod.like("join") &&
aMethod.returning("net.jxta.credential.Credential")
}
}
explorer.findAllClasses {
it.isExtending("net.jxta.service.Service") &&
it.hasAMethod {
it.isLike("join") &&
it.isReturning("net.jxta.credential.Credential")
}
}
it.hasAMethod.like("join").returning("net.jxta.credential.Credential")