# ConversionServiceAware class abstract interface

🫘 Interface for components that need access to a ConversionService.

The ConversionServiceAware interface enables components to perform runtime type conversions between different data types, formats, and representations using the framework's unified conversion system.

### Conversion Capabilities:

- Type Conversion: Convert between basic types (String, int, bool, etc.)
- Custom Converters: Register and use application-specific converters
- Format Parsing: Parse and format dates, numbers, and custom formats
- Collection Conversion: Convert between different collection types
- Null-Safe: Handle null values appropriately during conversion

### Framework Integration:

- Called during component initialization when ConversionService is available
- The service may be null if no conversion service is configured
- Default conversion service provides common type conversions

### Example Usage:

    @Component
    class ConfigurationProcessor implements ConversionServiceAware {
      ConversionService? _conversionService;

      @override
      void setConversionService(ConversionService? conversionService) {
        _conversionService = conversionService;
      }

      T getConfiguration<T>(String key, T defaultValue) {
        final value = _environment.getProperty(key);
        if (value == null) {
          return defaultValue;
        }

        return _conversionService?.convert<T>(value) ?? defaultValue;
      }

      List<int> parseIdList(String idListString) {
        return _conversionService?.convert<List<int>>(idListString) ?? [];
      }

      DateTime? parseDate(String dateString) {
        return _conversionService?.convert<DateTime>(dateString);
      }
    }

### Best Practices:

- Always provide fallback values when conversion may fail
- Handle conversion exceptions gracefully
- Use specific converter interfaces for complex conversion logic
- Consider performance implications for frequent conversions

See also:

- ConversionService for the conversion service interface
- Converter for custom type converter implementations
- `GenericConverter` for generic conversion implementations

## Properties

hashCode → int
  The hash code for this object.
  no setter inherited
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited

## Methods

noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
setConversionService(ConversionService? conversionService) → void
  Sets the ConversionService that this component can use for type conversions.
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited