@SuppressWarnings("unchecked")
    public static <T,U> T with(
            @DelegatesTo.Target("self") U self,
            @DelegatesTo(value=DelegatesTo.Target.class,
                    target="self",
                    strategy=Closure.DELEGATE_FIRST)
            @ClosureParams(FirstParam.class)
            Closure<T> closure) {
        return (T) with(self, false, (Closure<Object>)closure);
    }
@ SuppressWarnings ( "unchecked" ) public static < T , U > T with ( @ DelegatesTo . Target ( "self" ) U self , @ DelegatesTo ( value = DelegatesTo . Target . class , target = "self" , strategy = Closure . DELEGATE_FIRST ) @ ClosureParams ( FirstParam . class ) Closure < T > closure ) { return ( T ) with ( self , false , ( Closure < Object > ) closure ) ; }
Allows the closure to be called for the object reference self.
<p>
Any method invoked inside the closure will first be invoked on the
self reference. For instance, the following method calls to the append()
method are invoked on the StringBuilder instance:
<pre class="groovyTestCase">
def b = new StringBuilder().with {
append('foo')
append('bar')
return it
}
assert b.toString() == 'foobar'
</pre>
This is commonly used to simplify object creation, such as this example:
<pre>
def p = new Person().with {
firstName = 'John'
lastName = 'Doe'
return it
}
</pre>
The other typical usage, uses the self object while creating some value:
<pre>
def fullName = person.with{ "$firstName $lastName" }
</pre>

@param self    the object to have a closure act upon
@param closure the closure to call on the object
@return result of calling the closure
@see #with(Object, boolean, Closure)
@see #tap(Object, Closure)
@since 1.5.0