public static Field tryToGetFieldOfProperty()

in core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java [237:282]


    public static Field tryToGetFieldOfProperty(PropertyStorage storage, Class entity, String property)
    {
        if (isCachedField(storage, entity, property))
        {
            return getCachedField(storage, entity, property);
        }

        Field field = null;

        try
        {
            field = entity.getDeclaredField(property);
        }
        catch (Exception e)
        {
            try
            {
                try
                {
                    field = entity.getDeclaredField("_" + property);
                }
                catch (Exception e1)
                {
                    if (property.length() > 1
                            && Character.isUpperCase(property.charAt(0))
                            && Character.isUpperCase(property.charAt(1)))
                    {
                        //don't use Introspector#decapitalize here
                        field = entity.getDeclaredField(property.substring(0, 1).toLowerCase() + property.substring(1));
                    }
                    else
                    {
                        field = entity.getDeclaredField(Introspector.decapitalize(property));
                    }
                }
            }
            catch (NoSuchFieldException e1)
            {
                LOGGER.log(Level.FINEST, "field " + property + " or _" + property + " not found", e1);
            }
        }

        tryToCacheField(storage, entity, property, field);

        return field;
    }