Skip to content

Instantly share code, notes, and snippets.

@paulk-asert
Created December 3, 2014 10:30
Show Gist options
  • Save paulk-asert/10aeeb08ffb685268d9d to your computer and use it in GitHub Desktop.
Save paulk-asert/10aeeb08ffb685268d9d to your computer and use it in GitHub Desktop.
import groovy.transform.TypeChecked
interface ReadOnlyCollection {
boolean contains(Object o)
boolean isEmpty()
}
@TypeChecked(extensions='StructuralProvider.groovy')
def method() {
def list = ['cat', 'dog']
assert !(list instanceof ReadOnlyCollection)
ReadOnlyCollection roc = list //as ReadOnlyCollection
assert !roc.isEmpty()
assert roc.contains('cat')
}
method()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment