How do I convert ChangeSet code into SQL scripts using Java code

How do I convert ChangeSet code into SQL scripts using Java code

You can use the updateSQL Liquibase command, which will convert all of your xml/yaml/json changesets into sql statements in the Liquibase output.

https://docs.liquibase.com/commands/community/updatesql.html