private function parseData($data)
    {
        if ($data === null) {
            return $this->create('ResourceNull', $data);
        }

        if (is_array($data)) {
            return $this->create('ResourceCollection', $data);
        }

        if (! is_object($data)) {
            throw new ValidationException('Data value has to be null or an object, "' . gettype($data) . '" given.');
        }

        $object_keys = array_keys(get_object_vars($data));
        sort($object_keys);

        // the properties must be type and id or
        // the 3 properties must be type, id and meta
        if ($object_keys === ['id', 'type'] or $object_keys === ['id', 'meta', 'type']) {
            $resource = $this->create('ResourceIdentifier', $data);
        } else {
            // #Workaround: preset `data` with null, so ResourceItem can distinguish his parent between Document and ResourceCollection
            $this->set('data', null);
            $resource = $this->create('ResourceItem', $data);
        }

        return $resource;
    }