Interface Parser<T>
- Type Parameters:
T- the type to parse/serialize
- All Known Implementing Classes:
ConfigParser,DefaultConfigParser,StringHashMapParser
Deprecated, for removal: This API element is subject to removal in a future 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 TypeMethodDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Parses a raw object into the target type.Deprecated, for removal: This API element is subject to removal in a future version.Serializes an object to a storable format.
-
Method Details
-
parse
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
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)
-
ConfigConverterandConfigConverterFor; removed in the next version.