public function _apply($oldValue, $object, $key)
    {
        if ($oldValue == null)
        {
            return new AVRelation($object, $key, $this->targetClassName);
        } else if ($oldValue instanceof AVRelation)
        {
            if ($this->targetClassName != null && $oldValue->getTargetClass() !== $this->targetClassName)
            {
                throw new \Exception('Related object object must be of class ' . $this->targetClassName . ', but ' . $oldValue->getTargetClass() . ' was passed in.');
            }

            return $oldValue;
        } else
        {
            throw new \Exception("Operation is invalid after previous operation.");
        }
    }