Class NamedCoordinateReferenceSystemConverter

  • All Implemented Interfaces:
    SimpleValueConverter

    public class NamedCoordinateReferenceSystemConverter
    extends TypeConverter
    implements SimpleValueConverter
    A Morphia TypeConverter that knows how to turn things that are labelled with the Geometry interface into the correct concrete class, based on the GeoJSON type.

    Only implements the decode method as the concrete classes can encode themselves without needing a converter. It's when they come out of the database that there's not enough information for Morphia to automatically create Geometry instances.

    • Constructor Detail

      • NamedCoordinateReferenceSystemConverter

        public NamedCoordinateReferenceSystemConverter()
        Sets up this converter to work with things that implement the Geometry interface
    • Method Detail

      • decode

        public java.lang.Object decode​(java.lang.Class<?> targetClass,
                                       java.lang.Object fromDBObject,
                                       MappedField optionalExtraInfo)
        Description copied from class: TypeConverter
        decode the DBObject and provide the corresponding java (type-safe) object
        NOTE: optionalExtraInfo might be null
        Specified by:
        decode in class TypeConverter
        Parameters:
        targetClass - the class to create and populate
        fromDBObject - the DBObject to use when populating the new instance
        optionalExtraInfo - the MappedField that contains the metadata useful for decoding
        Returns:
        the new instance
      • encode

        public java.lang.Object encode​(java.lang.Object value,
                                       MappedField optionalExtraInfo)
        Description copied from class: TypeConverter
        encode the (type-safe) java object into the corresponding DBObject
        Overrides:
        encode in class TypeConverter
        Parameters:
        value - The object to encode
        optionalExtraInfo - the MappedField that contains the metadata useful for decoding
        Returns:
        the encoded version of the object
      • isSupported

        protected boolean isSupported​(java.lang.Class<?> c,
                                      MappedField optionalExtraInfo)
        Description copied from class: TypeConverter
        checks if the class is supported for this converter.
        Overrides:
        isSupported in class TypeConverter