public function setValue($value, EntityInterface $entity = null)
    {
        $attribute_validator = $this->getAttribute()->getValidator();
        $validation_result = $attribute_validator->validate($value, $entity);

        if ($validation_result->getSeverity() <= IncidentInterface::NOTICE) {
            $previous_native_value = $this->toNative();
            $this->value = $validation_result->getSanitizedValue();

            if (!$this->sameValueAs($previous_native_value)) {
                $value_changed_event = $this->createValueHolderChangedEvent($previous_native_value);
                $this->propagateValueChangedEvent($value_changed_event);
            }

            if ($this->value instanceof CollectionInterface) {
                $this->value->addListener($this);
            }
            if ($this->value instanceof EntityList) {
                $this->value->addEntityChangedListener($this);
            }
        }

        return $validation_result;
    }