Form for creating an entity create vs update

Hi everyone, is there a way to distinguish when i am creating or updating an entity in a form from the java controller?

Hi

import io.jmix.core.EntityStates;

@Autowired
private EntityStates entityStates;

@Subscribe
public void onBeforeShow(final BeforeShowEvent event) {
   TEntity entity = getEditedEntity();
   if ( entityStates.isNew(entity) ) {
  }
}

Do you mean something like this ?