Class ServiceBasedValueObjectConverter<O extends Identifiable,VO extends IdentifiableValueObject<O>>

java.lang.Object
ubic.gemma.persistence.util.ServiceBasedEntityConverter<O>
ubic.gemma.persistence.util.ServiceBasedValueObjectConverter<O,VO>
Type Parameters:
O - the type of value object this converter consumes and also produces (as inherited from ServiceBasedEntityConverter
VO - the type of value object this converter produces
All Implemented Interfaces:
org.springframework.core.convert.converter.ConditionalConverter, org.springframework.core.convert.converter.ConditionalGenericConverter, org.springframework.core.convert.converter.GenericConverter

public class ServiceBasedValueObjectConverter<O extends Identifiable,VO extends IdentifiableValueObject<O>> extends ServiceBasedEntityConverter<O> implements org.springframework.core.convert.converter.ConditionalGenericConverter
Perform conversion to value object by entity, ID and collections of entities and IDs and also to entity by ID and collection of IDs.

The converter recognize two cases: converting ServiceBasedValueObjectConverterServiceBasedValueObjectConverter and converting Collection of ServiceBasedValueObjectConverter to List of ServiceBasedValueObjectConverter by calling respectively BaseVoEnabledService.loadValueObject(Identifiable) and BaseVoEnabledService.loadValueObjects(Collection).

This implementation also work with supertypes of the designated ServiceBasedValueObjectConverter and subtypes of the ServiceBasedValueObjectConverter. For example, you can perform generic conversion to IdentifiableValueObject without having to mention the specific type of value object you ultimately want.

Author:
poirigui
See Also:
  • Constructor Details

  • Method Details

    • matches

      public boolean matches(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
      Specified by:
      matches in interface org.springframework.core.convert.converter.ConditionalConverter
      Overrides:
      matches in class ServiceBasedEntityConverter<O extends Identifiable>
    • convert

      public Object convert(@Nullable Object object, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
      Specified by:
      convert in interface org.springframework.core.convert.converter.GenericConverter
      Overrides:
      convert in class ServiceBasedEntityConverter<O extends Identifiable>