class ReflectionUtils {

    public static long getId( Object object )
    {
        try
        {
            Method method = object.getClass().getMethod( "getId" );

            return (Long) method.invoke( object );
        }
        catch ( NoSuchMethodException ex )
        {
            return -1;
        }
        catch ( InvocationTargetException ex )
        {
            return -1;
        }
        catch ( IllegalAccessException ex )
        {
            return -1;
        }
    }

}