Recycler { public final boolean recycle(T o, Handle<T> handle) { if (handle == NOOP_HANDLE) { return false; } DefaultHandle<T> h = (DefaultHandle<T>) handle; if (h.stack.parent != this) { return false; } h.recycle(o); return true; } protected  Recycler(); protected  Recycler(int maxCapacity); @SuppressWarnings("unchecked") final T get(); final boolean recycle(T o, Handle<T> handle);  }
@Test(expected = IllegalStateException.class) public void testMultipleRecycle() { RecyclableObject object = RecyclableObject.newInstance(); object.recycle(); object.recycle(); }
@Test public void testRecycle() { RecyclableObject object = RecyclableObject.newInstance(); object.recycle(); RecyclableObject object2 = RecyclableObject.newInstance(); assertSame(object, object2); object2.recycle(); }
@Test public void testRecycleDisable() { DisabledRecyclableObject object = DisabledRecyclableObject.newInstance(); object.recycle(); DisabledRecyclableObject object2 = DisabledRecyclableObject.newInstance(); assertNotSame(object, object2); object2.recycle(); }