Sapphire Developer Guide > Services

MasterConversionService

MasterConversionService converts an object to the specified type by delegating to available ConversionService and UniversalConversionService implementations. If object is null or is already of desired type, the object is returned unchanged.

An implementation of this service is provided with Sapphire. This service is not intended to be implemented by adopters. See ConversionService instead.

Example

In this example, an IFile is converted to a Resource as part of instantiating the model. Note how this code is not aware of the details of the conversion or what type of a resource is created.

IFile file = project.getFile( "contacts.xml" )
Resource resource = ContactRepository.TYPE.service( MasterConversionService.class ).convert( file, Resource.class );
ContactRepository model = ContactRepository.TYPE.instantiate( resource );