Skip to content

Instantly share code, notes, and snippets.

@namuan
Created October 25, 2013 14:04
Show Gist options
  • Save namuan/7155187 to your computer and use it in GitHub Desktop.
Save namuan/7155187 to your computer and use it in GitHub Desktop.
Find annotation of groovy class fields
ApiCampaign a = new ApiCampaign()
a.properties.each { property ->
a.class.declaredFields.find { field ->
if (field.name == property.key && SupportedApiVersion in field.declaredAnnotations*.annotationType()) {
def parameter = field.getAnnotation(SupportedApiVersion)
println "Property with name " + property.key + " with parameter " + parameter.atLeast()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment