protected Object getBean(Token token) {
        Object value;
        if (token.getAlternativeValue() != null) {
            if (token.getDirectiveType() == TokenDirectiveType.FIELD) {
                Field field = (Field)token.getAlternativeValue();
                if (Modifier.isStatic(field.getModifiers())) {
                    value = ReflectionUtils.getField(field, null);
                } else {
                    Class<?> cls = field.getDeclaringClass();
                    Object target = activity.getBean(cls);
                    value = ReflectionUtils.getField(field, target);
                }
            } else if (token.getDirectiveType() == TokenDirectiveType.METHOD) {
                Method method = (Method)token.getAlternativeValue();
                if (Modifier.isStatic(method.getModifiers())) {
                    value = ReflectionUtils.invokeMethod(method, null);
                } else {
                    Class<?> cls = method.getDeclaringClass();
                    Object target = activity.getBean(cls);
                    value = ReflectionUtils.invokeMethod(method, target);
                }
            } else {
                Class<?> cls = (Class<?>)token.getAlternativeValue();
                try {
                    value = activity.getBean(cls);
                } catch (RequiredTypeBeanNotFoundException | NoUniqueBeanException e) {
                    if (token.getGetterName() != null) {
                        try {
                            value = BeanUtils.getProperty(cls, token.getGetterName());
                            if (value == null) {
                                value = token.getDefaultValue();
                            }
                            return value;
                        } catch (InvocationTargetException e2) {
                            // ignore
                        }
                    }
                    throw e;
                }
                if (value != null && token.getGetterName() != null) {
                    value = getBeanProperty(value, token.getGetterName());
                }
            }
        } else {
            value = activity.getBean(token.getName());
            if (value != null && token.getGetterName() != null) {
                value = getBeanProperty(value, token.getGetterName());
            }
        }
        if (value == null) {
            value = token.getDefaultValue();
        }
        return value;
    }
protected Object getBean ( Token token ) { Object value ; if ( token . getAlternativeValue ( ) != null ) { if ( token . getDirectiveType ( ) == TokenDirectiveType . FIELD ) { Field field = ( Field ) token . getAlternativeValue ( ) ; if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { value = ReflectionUtils . getField ( field , null ) ; } else { Class < ? > cls = field . getDeclaringClass ( ) ; Object target = activity . getBean ( cls ) ; value = ReflectionUtils . getField ( field , target ) ; } } else if ( token . getDirectiveType ( ) == TokenDirectiveType . METHOD ) { Method method = ( Method ) token . getAlternativeValue ( ) ; if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { value = ReflectionUtils . invokeMethod ( method , null ) ; } else { Class < ? > cls = method . getDeclaringClass ( ) ; Object target = activity . getBean ( cls ) ; value = ReflectionUtils . invokeMethod ( method , target ) ; } } else { Class < ? > cls = ( Class < ? > ) token . getAlternativeValue ( ) ; try { value = activity . getBean ( cls ) ; } catch ( RequiredTypeBeanNotFoundException | NoUniqueBeanException e ) { if ( token . getGetterName ( ) != null ) { try { value = BeanUtils . getProperty ( cls , token . getGetterName ( ) ) ; if ( value == null ) { value = token . getDefaultValue ( ) ; } return value ; } catch ( InvocationTargetException e2 ) { } } throw e ; } if ( value != null && token . getGetterName ( ) != null ) { value = getBeanProperty ( value , token . getGetterName ( ) ) ; } } } else { value = activity . getBean ( token . getName ( ) ) ; if ( value != null && token . getGetterName ( ) != null ) { value = getBeanProperty ( value , token . getGetterName ( ) ) ; } } if ( value == null ) { value = token . getDefaultValue ( ) ; } return value ; }
Returns the bean instance that matches the given token.

@param token the token
@return an instance of the bean