Interface Parser<T>

Type Parameters:
T - the type to parse/serialize
All Known Implementing Classes:
ConfigParser, DefaultConfigParser, StringHashMapParser

@Deprecated(since="6.3.0", forRemoval=true) public interface Parser<T>
Deprecated, for removal: This API element is subject to removal in a future version.
Use ConfigConverter and ConfigConverterFor; removed in the next version.
Generic parser interface for serialization and deserialization.

Provides bidirectional conversion between objects and their serialized form. Implementations should handle type conversion for configuration files, database storage, or other persistence mechanisms.

Example Implementation:


 public class LocationParser implements Parser<Location> {
     public Location parse(Object object) {
         Map<String, Object> map = (Map<String, Object>) object;
         return new Location(
             Bukkit.getWorld((String) map.get("world")),
             (double) map.get("x"),
             (double) map.get("y"),
             (double) map.get("z")
         );
     }

     public Object serialize(Location location) {
         Map<String, Object> map = new HashMap<>();
         map.put("world", location.getWorld().getName());
         map.put("x", location.getX());
         map.put("y", location.getY());
         map.put("z", location.getZ());
         return map;
     }
 }
 
Since:
6.0.0
Author:
wisdomme
See Also:
Scheduled removal version:
6.4.0
  • Method Summary

    Modifier and Type
    Method
    Description
    parse(Object object)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Parses a raw object into the target type.
    serialize(T object)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Serializes an object to a storable format.
  • Method Details

    • parse

      T parse(Object object)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parses a raw object into the target type.
      Parameters:
      object - the raw object to parse (typically from configuration)
      Returns:
      the parsed object of type T
    • serialize

      Object serialize(T object)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Serializes an object to a storable format.
      Parameters:
      object - the object to serialize
      Returns:
      the serialized form (typically Map, List, or primitive types)