Programmatically set property based on other properties in a custom entity
For a custom entity type, you can override EntityStorage::doPreSave() in your entity class:

function doPreSave(EntityInterface $entity) {
  parent::doPreSave();

  // Perform field manipulation here.

  return $entity-&gt;id();
}