public static final String getStaticFieldName ( Object value , Class < ? > clazz ) throws Exception { Field [ ] fields = clazz . getFields ( ) ; for ( Field field : fields ) { Object fVal = field . get ( null ) ; if ( fVal != null && fVal . equals ( value ) ) { return field . getName ( ) ; } } return null ; }
Returns the name of the static field that corresponds to the given value