I have created a typesafe simple PTQL for ProcessFinder. I found that it was error prone to use the string based query, and thus I created a type safe way of creating simple PTQL queries.
ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), "Hopefully There is no Process called this").createQuery(); List<Long> find2 = spm.find(ptql); Assert.assertTrue(find2.size() == 0); ptql = new SimplePTQL.Builder(SimplePTQL.PID_PID(), SimplePTQL.GT(), "1").createQuery(); List<Long> find3 = spm.find(ptql); Assert.assertTrue(find3.size() > 1);
And this is how you use the Args.
public void realArguments() throws Exception { if (PlatformUtils.isWindows()) { throw new SkipException("Sleep only works on unix"); } Process process = new ProcessBuilder("sleep", "60s").start(); Assert.assertNotNull(process); SimplePTQL ptql = new SimplePTQL.Builder(SimplePTQL.STATE_NAME(), SimplePTQL.EQ(), "sleep") .addArgs(1, SimplePTQL.EQ(), "60s", Strategy.NOT_ESCAPE).createQuery();
Any comments/feedback appreciated. I am sure there might be errors in the code, and I also want to include Env and Modules, however, I don't know how they work since I couldn't find any documentation on them. Would love to include support for that as well.
PS: Feel free to include this in the distribution, or work on it if you feel to do so