Class ServiceBasedEntityConverter<O extends Identifiable>

java.lang.Object
ubic.gemma.persistence.util.ServiceBasedEntityConverter<O>
Type Parameters:
O - the type of entity this converter produces
All Implemented Interfaces:
org.springframework.core.convert.converter.ConditionalConverter, org.springframework.core.convert.converter.ConditionalGenericConverter, org.springframework.core.convert.converter.GenericConverter
Direct Known Subclasses:
ServiceBasedValueObjectConverter

public class ServiceBasedEntityConverter<O extends Identifiable> extends Object implements org.springframework.core.convert.converter.ConditionalGenericConverter
Performs conversion by identifier and collection of identifier for a BaseReadOnlyService.

The converter recognize two cases: LongServiceBasedEntityConverter and Collection of Long to List of ServiceBasedEntityConverter using BaseReadOnlyService.load(Long) and BaseReadOnlyService.load(Collection) respectively.

The conversion also works with supertypes of ServiceBasedEntityConverter up to Identifiable.

Author:
poirigui
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.core.convert.converter.GenericConverter

    org.springframework.core.convert.converter.GenericConverter.ConvertiblePair
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ServiceBasedEntityConverter(BaseReadOnlyService<? extends O> service, Class<O> entityType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
     
    Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair>
     
    boolean
    matches(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • convertibleTypes

      protected final Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair> convertibleTypes
  • Constructor Details

    • ServiceBasedEntityConverter

      public ServiceBasedEntityConverter(BaseReadOnlyService<? extends O> service, Class<O> entityType)
  • 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
    • getConvertibleTypes

      public Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair> getConvertibleTypes()
      Specified by:
      getConvertibleTypes in interface org.springframework.core.convert.converter.GenericConverter
    • convert

      public Object convert(@Nullable Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
      Specified by:
      convert in interface org.springframework.core.convert.converter.GenericConverter