diff options
Diffstat (limited to 'src/main/java/ftbsc/lll/mapper/IMappingFormat.java')
-rw-r--r-- | src/main/java/ftbsc/lll/mapper/IMappingFormat.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/lll/mapper/IMappingFormat.java b/src/main/java/ftbsc/lll/mapper/IMappingFormat.java new file mode 100644 index 0000000..00b1e0d --- /dev/null +++ b/src/main/java/ftbsc/lll/mapper/IMappingFormat.java @@ -0,0 +1,49 @@ +package ftbsc.lll.mapper; + +import ftbsc.lll.exceptions.MalformedMappingsException; +import ftbsc.lll.mapper.tools.Mapper; + +import java.util.List; + +/** + * The shared interface between all mappers. + */ +public interface IMappingFormat { + /** + * Checks whether this mapper can process the given lines. + * @param lines the lines to read + * @return whether this type of mapper can process these lines + */ + boolean claim(List<String> lines); + + /** + * Defines a priority for this implementation: the higher the number, + * the higher the priority. + * This is used to resolve conflicts when multiple mappers attempt to + * {@link #claim(List) claim} a given mapping file. + * @return the priority + */ + default int priority() { + return 0; + } + + /** + * Creates a {@link Mapper} given the lines, ignoring errors depending on the given flag. + * @param lines the lines to read + * @param ignoreErrors try to ignore errors and keep going + * @return the {@link Mapper} + * @throws MalformedMappingsException if an error is encountered and ignoreErrors is false + */ + Mapper getMapper(List<String> lines, boolean ignoreErrors) throws MalformedMappingsException; + + /** + * Creates a {@link Mapper} given the lines, ignoring errors depending on the given flag, and + * returns its inverted form. + * @param lines the lines to read + * @param ignoreErrors try to ignore errors and keep going + * @throws MalformedMappingsException if an error is encountered and ignoreErrors is false + */ + default Mapper getInvertedMapper(List<String> lines, boolean ignoreErrors) throws MalformedMappingsException { + return this.getMapper(lines, ignoreErrors).getInverted(); + } +} |