### Question:
Limit implements NullaryPredicate, Predicate<Object>, BinaryPredicate<Object, Object> { public boolean test() { if (state.get() < max) { state.incrementAndGet(); return true; } return false; } Limit(int count); boolean test(); boolean test(Object obj); boolean test(Object a, Object b); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static Limit of(int count);  }### Answer:
@Test public void testZero() throws Exception { NullaryPredicate p = new Limit(0); assertTrue(! p.test()); assertTrue(! p.test()); assertTrue(! p.test()); }
@Test public void testTestNullary() throws Exception { NullaryPredicate p = new Limit(3); assertTrue(p.test()); assertTrue(p.test()); assertTrue(p.test()); assertTrue(! p.test()); }
@Test public void testTestUnary() throws Exception { Predicate<Object> p = new Limit(3); assertTrue(p.test(null)); assertTrue(p.test(null)); assertTrue(p.test(null)); assertTrue(! p.test(null)); }
@Test public void testTestBinary() throws Exception { BinaryPredicate<Object, Object> p = new Limit(3); assertTrue(p.test(null,null)); assertTrue(p.test(null,null)); assertTrue(p.test(null,null)); assertTrue(! p.test(null,null)); }