Class A2AMappers_v0_3
java.lang.Object
org.a2aproject.sdk.compat03.conversion.mappers.config.A2AMappers_v0_3
Singleton factory for MapStruct mapper instances in the v0.3 to v1.0 conversion layer.
This factory provides centralized access to mapper implementations, ensuring that each mapper interface has exactly one instance (singleton pattern). MapStruct generates implementation classes with an "Impl" suffix at compile time, and this factory uses reflection to instantiate and cache them.
Example usage:
public interface TaskStateMapper {
TaskStateMapper INSTANCE = A03Mappers.getMapper(TaskStateMapper.class);
org.a2aproject.sdk.spec.TaskState toV10(
org.a2aproject.sdk.compat03.spec.TaskState v03);
}
Thread Safety: This factory uses ConcurrentHashMap to ensure thread-safe
lazy initialization of mapper instances.- See Also:
-
Method Summary
-
Method Details
-
getMapper
Returns the singleton instance of the specified mapper interface.This method uses reflection to load the MapStruct-generated implementation class (interface name + "Impl" suffix) and caches it for future use. If the implementation class cannot be loaded or instantiated, a
RuntimeExceptionis thrown.- Type Parameters:
T- the mapper type- Parameters:
mapperInterface- the mapper interface class (e.g.,TaskStateMapper.class)- Returns:
- the singleton instance of the mapper
- Throws:
RuntimeException- if the mapper implementation cannot be loaded or instantiated
-