Function with return type

I would like to create a rule that returns a Boolean. This is what I currently have:

val org.eclipse.xtext.xbase.lib.Functions$Function2 checkStateIsBefore = [
    org.openhab.core.types.State state, DateTime checkDateTime |
        if (state == Uninitialized) {
  			return true;
		} else {
			var DateTime stateDateTime = state as DateTime
			return stateDateTime.isBefore(checkDateTime)

But the return type of the apply() method is Object. How can I set the return type to Boolean?
The Eclipse documentation does contain a return value: Link

Lambdas return an Object. Period. But a Boolean is an Object, so your caller just needs to cast it to a Boolean to use it as such.

Boolean rval = checkStateIsBefore.apply(state, checkDateTime) as Boolean

Thanks for the tipp, that works perfectly.