public static <U> WithStaticFinder<U> use(Class<U> cls, Object testFinder) {

    WithStaticFinder<U> with = new WithStaticFinder<>(cls);
    with.as(testFinder);
    with.useTestDouble();
    return with;
  }
public static < U > WithStaticFinder < U > use ( Class < U > cls , Object testFinder ) { WithStaticFinder < U > with = new WithStaticFinder < > ( cls ) ; with . as ( testFinder ) ; with . useTestDouble ( ) ; return with ; }
Set the given test double onto the given class returning the WithStaticFinder.
<p>
Use restore to put the original finder back onto the class.
</p>

<pre>{@code

// Replace the finder with TDCustFinder
WithStaticFinder with = WithStaticFinder.use(Customer.class, new TDCustFinder());
try {
// perform some test
Customer jim = Customer.find.byName("jim");

} finally {
// restore the original finder
with.restoreOriginal();
}

}</pre>