Class SchemaVersionMapper

java.lang.Object
org.cyclonedx.gradle.model.SchemaVersionMapper

public final class SchemaVersionMapper extends Object
One-way mapper from Core's Version to the plugin-internal SchemaVersion. Only the two version-conditional decision points in SbomBuilder.buildMetadata() need this translation; every other use of Version in the plugin (hash calculation, BOM serialization/validation, the schema-version CLI/DSL mapping in CyclonedxUtils.schemaVersion(String)) keeps using the Core type directly and is untouched by this class.
  • Method Details

    • from

      public static SchemaVersion from(org.cyclonedx.Version coreVersion)
      Maps a Core Version to the corresponding SchemaVersion.

      Comparisons are ordinal, mirroring the Version.compareTo(...) checks this type replaces, so a genuinely unknown future Version constant (newer than Version.VERSION_17) is never rejected — it falls back to the newest known schema's thresholds (SchemaVersion.VERSION_17), staying exactly as permissive as the raw compareTo logic it replaces.

      Parameters:
      coreVersion - the Core schema version to translate
      Returns:
      the corresponding internal SchemaVersion