Class MappingFileReader
java.lang.Object
fr.skytasul.reflection.mappings.files.MappingFileReader
-
Constructor Summary
ConstructorsConstructorDescriptionMappingFileReader(@NotNull MappingType mappingType, @NotNull List<String> lines) Creates a reader for a composite mappings file.MappingFileReader(@NotNull MappingType mappingType, @NotNull List<String> lines, @NotNull Version version) Creates a reader for a plain mappings file, associated with its version. -
Method Summary
Modifier and TypeMethodDescriptiongetBestMatchedVersion(@NotNull Version targetVersion, @NotNull List<@NotNull Version> availableVersions) Returns the version present in the available versions list that matches the best the target version.@NotNull MappingsgetParsedMappings(@NotNull Version version) keepBestMatchedVersion(@NotNull Version targetVersion) booleankeepOnlyVersion(@NotNull Version version) void
-
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 filelines- 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 filelines- of the mappings fileversion- version of the mappings- Throws:
IOException
-
-
Method Details
-
getAvailableVersions
-
keepOnlyVersion
-
keepBestMatchedVersion
-
parseMappings
public void parseMappings() -
getParsedMappings
-
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 versionavailableVersions- available versions (must be sorted !)- Returns:
- an optional containing a matching version if present, otherwise an empty optional
-