public static Method findGetterMethod()

in lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java [195:230]


    public static Method findGetterMethod( Method method )
    {
        if ( method.getName().startsWith( "get" ) || method.getName().startsWith( "is" ) )
        {
            return method;
        }

        String propertyName = StringUtil.toUpperCamelCase( extractPropertyName( method.getName() ) );

        Class<?> type = method.getParameterTypes()[0];
        Class<?> clazz = method.getDeclaringClass();
        String getterObjectName = "get" + propertyName;
        String getterBooleanName = "is" + propertyName;

        try
        {
            return clazz.getDeclaredMethod( getterObjectName, type );
        }
        catch ( Exception e )
        {
            if ( type == boolean.class )
            {
                try
                {
                    return clazz.getDeclaredMethod( getterBooleanName, type );
                }
                catch ( Exception ex )
                {
                    // Intentionally left blank - just fall through
                }
            }

            // Seems there's no setter, so ignore all exceptions
            return null;
        }
    }