class BeanExtractor implements Extractor {

    @SuppressWarnings("PMD.CompareObjectsWithEquals")
    public Object extractObject(ObjectToJsonConverter pConverter, Object pValue,
                                Stack<String> pPathParts, boolean jsonify)
            throws AttributeNotFoundException {
        // Wrap fault handler if a wildcard path pattern is present
        ValueFaultHandler faultHandler = pConverter.getValueFaultHandler();
        String pathPart = pPathParts.isEmpty() ? null : pPathParts.pop();
        if (pathPart != null) {
            // Still some path elements available, so dive deeper
            Object attributeValue = extractBeanPropertyValue(pValue, pathPart, faultHandler);
            return pConverter.extractObject(attributeValue, pPathParts, jsonify);
        } else {
            if (jsonify) {
                // We need the jsonfied value from here on.
                return exctractJsonifiedValue(pConverter, pValue, pPathParts);
            } else {
                // No jsonification requested, hence we are returning the object itself
                return pValue;
            }
        }
    }

}