Module gomint.api

Interface Converter

    • Method Detail

      • toConfig

        Object toConfig​(Class<?> type,
                        Object object,
                        ParameterizedType parameterizedType)
                 throws Exception
        This method gets called on save. It gets the Fields Type and the object the Config wants to save into it. This is needed to pretty print INTO the config.
        Parameters:
        type - The type (Class) of the Field
        object - The object which is stored in the Config Object
        parameterizedType - If the Class has some generic information this is the information otherwise this is null
        Returns:
        An Object (mostly a Map or a List)
        Throws:
        Exception - Some generic exception when something went wrong. This gets caught by the converter
      • fromConfig

        Object fromConfig​(Class<?> type,
                          Object object,
                          ParameterizedType parameterizedType)
                   throws Exception
        This method gets called when we want to load something out of the File. You get that what you give into the Config via toConfig as Object passed. The type is the Destination Field Type which this Object should be layed in.
        Parameters:
        type - The type (Class) of the Field
        object - The Object from toConfig
        parameterizedType - If the Class has some generic information this is the information otherwise this is null
        Returns:
        The correct Object which can be hold by the Field
        Throws:
        Exception - Some generic exception when something went wrong. This gets caught by the converter
      • supports

        boolean supports​(Class<?> type)
        This checks if this converter can convert the given Class
        Parameters:
        type - The type (Class) of the Field to check
        Returns:
        true if this can convert that otherwise false