Class DescriptorScanner

  • All Implemented Interfaces:
    de.griefed.serverpackcreator.api.modscanning.ModJarScanner

    
    public abstract class DescriptorScanner
     implements ModJarScanner
                        

    Base for scanners that read one descriptor file out of each jar, owning the part every one of them shares: walk the jars, and turn any failure on a single jar into that jar's default ScannedMod instead of letting it abort the scan.

    Subclasses implement read for one jar and may simply throw — which is why scan is final. The total-result contract of ModJarScanner is the one thing no scanner may get wrong, and putting it here means it cannot drift between the five implementations that used to each hold a copy.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      String getScanAnnouncement()
      abstract ScannedMod read(File modJar) Read a single jar's descriptor into the verdict for that mod.
      final List<ScannedMod> scan(Collection<File> jarFiles) Read every jar in jarFiles and report what each declared.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DescriptorScanner

        DescriptorScanner()
    • Method Detail

      • read

         abstract ScannedMod read(File modJar)

        Read a single jar's descriptor into the verdict for that mod.

        Implementations are free to throw: scan catches everything and falls back to the defaults, so there is no need to guard the jar-level failure modes here. It is public because the distinction between what it throws is meaningful — MissingDescriptorException means the jar simply belongs to another loader, anything else means the jar could not be read — and that distinction is only observable here; scan deliberately flattens both to a default entry.

      • scan

         final List<ScannedMod> scan(Collection<File> jarFiles)

        Read every jar in jarFiles and report what each declared.

        Returns:

        One entry per input jar, in input order — never fewer, whatever a jar contained.