|
Groovy example source code file (AnnotationClosureOwnerCallTest.groovy)
The Groovy AnnotationClosureOwnerCallTest.groovy source code
package gls.annotations.closures
class AnnotationClosureOwnerCallTest extends AnnotationClosureExhaustiveTestSupport {
Class getAnnotationClass() { AnnWithClassElement }
Class getAnnotatedClass() { CallOnOwner }
void verify(Class closureClass) {
def closure = closureClass.newInstance(this, null)
closure.resolveStrategy = Closure.OWNER_ONLY
assert closure.call() == 42
}
def answer() { 42 }
}
@AnnWithClassElement(elem = { owner.answer() })
class CallOnOwner {
@AnnWithClassElement(elem = { owner.answer() })
private aField
@AnnWithClassElement(elem = { owner.answer() })
def aProperty
@AnnWithClassElement(elem = { owner.answer() })
def aMethod(@AnnWithClassElement(elem = { owner.answer() }) aParam) {
@AnnWithClassElement(elem = { owner.answer() })
def aLocal
}
}
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy AnnotationClosureOwnerCallTest.groovy source code file: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.