Sirius api and equivalent functions

Hi there,

I have a Capella addon whose purpose is to dynamically create diagrams. Therefore I use the isRefreshActivatedOnRepresentationOpening function.
The problem is that between versions 1.4.2 of Capella or 6.3.3 of Sirius, the call was made in the following way:

if(DialectUIManager.INSTANCE.isRefreshActivatedOnRepresentationOpening()) {

In Capella 5.1.0 version, the call is now made as follows:

if(session.getSiriusPreferences().isRefreshOnRepresentationOpening()) {


I would like this addon to be compatible with at least these two versions. Java does not allow conditional compilation, what strategy, possibly using maven packages, could you advise me to make the compilation as transparent as possible and avoiding duplicating my project.
Moreover, I also noticed that in the new versions of Sirius and therefore in terms of Capella, the Session object no longer exists. Where can I find an equivalent of the isRefreshActivatedOnRepresentationOpening method in these new versions?

Thank you for your answers.