How can I configure OWASP dependency-check on Jenkins using script console?

How can I transform this XML file to Groovy script in order to configure dependency-check (Global Tool Configuration) on Jenkins?

This is the XML org.jenkinsci.plugins.DependencyCheck.DependencyCheckToolBuilder.xml file:

<?xml version='1.1' encoding='UTF-8'?>
<org.jenkinsci.plugins.DependencyCheck.DependencyCheckToolBuilder_-DependencyCheckToolBuilderDescriptor plugin="dependency-check-jenkins-plugin@5.1.1">
  <installations>
    <org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation>
      <name>test-dependency-check</name>
      <home></home>
      <properties>
        <hudson.tools.InstallSourceProperty>
          <installers>
            <org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstaller>
              <id>8.2.1</id>
            </org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstaller>
          </installers>
        </hudson.tools.InstallSourceProperty>
      </properties>
    </org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation>
  </installations>
</org.jenkinsci.plugins.DependencyCheck.DependencyCheckToolBuilder_-DependencyCheckToolBuilderDescriptor>

This is the groovy code.

      import hudson.model.*
      import hudson.tools.*
      import jenkins.model.*
      import org.jenkinsci.plugins.DependencyCheck.*

      String name = 'test-dependency-check'
      String id = '8.2.1'

      def instance = Jenkins.getInstance()
      def descriptor = instance.getDescriptor(DependencyCheckToolBuilder.DependencyCheckToolBuilderDescriptor.class)
      def installations = descriptor.getInstallations()

      def installation = new DependencyCheckInstallation(name, null)
      def properties = new InstallSourceProperty([new DependencyCheckInstaller(id)])
      installation.setProperties(properties)

      installations.add(installation)
      descriptor.save()

Im not sure if I can pass the class or not.