* Copyright 2011-2013 Project Funcito Contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
import static org.funcito.FuncitoPlay2.*;
public static final Function<MyClass, String> getMyString = functionFor(stubbedCallsTo.getMyString());
// alternative single line syntax
public static final Function<MyClass, String> getMyStringF2 = functionFor(callsTo(MyClass.class).getMyString());
// demonstrating F.Callback creation around a method call that has a return value.
public static final F.Callback<MyClass> incAndReturn = callbackFor(stubbedCallsTo.incAndReturn());
// demonstrating F.Callback creation around a void method call.
// Note that for void version, the wrapped method call must be "prepared" before the F.Callback is created. Also,
// to be able to assign to a static field via an initializer, prepareVoid() requires a static block. If assignment
// were to a non-static field, a non-static block would be sufficient. If assignment to a F.Callback variable is not
// done in a field initializer (i.e., a local variable assignment or a field assignment in a method or execution
// block), then no-extra "blocking" is needed for the prepareVoid() call.
// I did not include demonstration code for using the Callback, because to do so requires creating a Promise,
// which in the earliest version of Play! 2 requires the Scala system to be available at runtime. So simply
// see above field declarations for example of how to create Callback objects