spring-data-elasticsearch CustomGeoModule 源码

  • 2022-08-16
  • 浏览 (13)

spring-data-elasticsearch CustomGeoModule 代码

文件路径:/src/main/java/org/springframework/data/elasticsearch/core/geo/CustomGeoModule.java

package org.springframework.data.elasticsearch.core.geo;

import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.data.geo.Point;

class PointSerializer extends JsonSerializer<Point> {
	@Override
	public void serialize(Point value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
		gen.writeObject(GeoPoint.fromPoint(value));
	}
}

class PointDeserializer extends JsonDeserializer<Point> {
	@Override
	public Point deserialize(JsonParser p, DeserializationContext context) throws IOException {
		return GeoPoint.toPoint(p.readValueAs(GeoPoint.class));
	}
}

相关信息

spring-data-elasticsearch 源码目录

相关文章

spring-data-elasticsearch GeoBox 源码

spring-data-elasticsearch GeoJson 源码

spring-data-elasticsearch GeoJsonGeometryCollection 源码

spring-data-elasticsearch GeoJsonLineString 源码

spring-data-elasticsearch GeoJsonMultiLineString 源码

spring-data-elasticsearch GeoJsonMultiPoint 源码

spring-data-elasticsearch GeoJsonMultiPolygon 源码

spring-data-elasticsearch GeoJsonPoint 源码

spring-data-elasticsearch GeoJsonPolygon 源码

spring-data-elasticsearch GeoPoint 源码

0  赞