Class MappingFileReader

java.lang.Object
fr.skytasul.reflection.mappings.files.MappingFileReader

public class MappingFileReader extends Object
  • Constructor Details

    • MappingFileReader

      public MappingFileReader(@NotNull @NotNull MappingType mappingType, @NotNull @NotNull List<String> lines) throws IOException
      Creates a reader for a composite mappings file.
      Parameters:
      mappingType - type of mappings in this file
      lines - of the mappings file
      Throws:
      IOException
    • MappingFileReader

      public MappingFileReader(@NotNull @NotNull MappingType mappingType, @NotNull @NotNull List<String> lines, @NotNull @NotNull Version version) throws IOException
      Creates a reader for a plain mappings file, associated with its version.
      Parameters:
      mappingType - type of mappings in this file
      lines - of the mappings file
      version - version of the mappings
      Throws:
      IOException
  • Method Details

    • getAvailableVersions

      @NotNull public @NotNull List<Version> getAvailableVersions()
    • keepOnlyVersion

      public boolean keepOnlyVersion(@NotNull @NotNull Version version)
    • keepBestMatchedVersion

      @NotNull public @NotNull Optional<Version> keepBestMatchedVersion(@NotNull @NotNull Version targetVersion)
    • parseMappings

      public void parseMappings()
    • getParsedMappings

      @NotNull public @NotNull Mappings getParsedMappings(@NotNull @NotNull Version version)
    • getBestMatchedVersion

      @NotNull public static @NotNull Optional<Version> getBestMatchedVersion(@NotNull @NotNull Version targetVersion, @NotNull @NotNull List<@NotNull Version> availableVersions)
      Returns the version present in the available versions list that matches the best the target version.

      If there is a perfect match (i.e. the target version is present in the list) then the target version is returned.

      If there is no perfect match but a version lower than the target is present, it will be returned.

      If only greater versions are available, then an empty Optional is returned.

      Parameters:
      targetVersion - target version
      availableVersions - available versions (must be sorted !)
      Returns:
      an optional containing a matching version if present, otherwise an empty optional