Return to Snippet

Revision: 23743
at February 12, 2010 02:05 by alun


Updated Code
def getFieldValue = { obj, fieldName ->
    def fields = obj.class.getDeclaredFields()
    Field field = fields.find { it.name == fieldName }
    field.setAccessible( true )
    return field.get( obj )
}

Revision: 23742
at February 12, 2010 02:05 by alun


Updated Code
def getFieldValue = { obj, fieldName ->
def fields = obj.class.getDeclaredFields()
Field field = fields.find { it.name == fieldName }
field.setAccessible( true )
return field.get( obj )
}

Revision: 23741
at February 12, 2010 02:04 by alun


Initial Code
def getFieldValue = { obj, fieldName ->
def fields = SLF4JLocationAwareLog.class.getDeclaredFields()
Field field = fields.find { it.name == fieldName }
field.setAccessible( true )
return field.get( obj )
}

Initial URL

                                

Initial Description
Closure to help getting values of private fields

Initial Title
get private field value

Initial Tags

                                

Initial Language
Groovy