Trying to add a custom TTL value for each of the document we insert in Spring Boot

At the entity level we can have a TTL value for each of the document. however that is going to be the same, what I want is, I want to have the TTl value based of some logic for a document.