get private field value


/ Published in: Groovy
Save to your folder(s)

Closure to help getting values of private fields


Copy this code and paste it in your HTML
  1. def getFieldValue = { obj, fieldName ->
  2. def fields = obj.class.getDeclaredFields()
  3. Field field = fields.find { it.name == fieldName }
  4. field.setAccessible( true )
  5. return field.get( obj )
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.