/** * @author Christoph Strobl */ @Data public class Planet { final @Id String name; final @GeoSpatialIndexed Point coordinates; }
/** * Creates {@link IndexDefinition} wrapped in {@link IndexDefinitionHolder} out of {@link GeoSpatialIndexed} for * {@link MongoPersistentProperty}. * * @param dotPath The properties {@literal "dot"} path representation from its document root. * @param collection * @param persistentProperty * @return */ @Nullable protected IndexDefinitionHolder createGeoSpatialIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) { GeoSpatialIndexed index = persistentProperty.findAnnotation(GeoSpatialIndexed.class); if (index == null) { return null; } GeospatialIndex indexDefinition = new GeospatialIndex(dotPath); indexDefinition.withBits(index.bits()); indexDefinition.withMin(index.min()).withMax(index.max()); if (!index.useGeneratedName()) { indexDefinition.named(pathAwareIndexName(index.name(), dotPath, persistentProperty)); } indexDefinition.typed(index.type()).withBucketSize(index.bucketSize()).withAdditionalField(index.additionalField()); return new IndexDefinitionHolder(dotPath, indexDefinition, collection); }
/** * Creates {@link IndexDefinition} wrapped in {@link IndexDefinitionHolder} out of {@link GeoSpatialIndexed} for * {@link MongoPersistentProperty}. * * @param dotPath The properties {@literal "dot"} path representation from its document root. * @param collection * @param persistentProperty * @return */ @Nullable protected IndexDefinitionHolder createGeoSpatialIndexDefinition(String dotPath, String collection, MongoPersistentProperty persistentProperty) { GeoSpatialIndexed index = persistentProperty.findAnnotation(GeoSpatialIndexed.class); if (index == null) { return null; } GeospatialIndex indexDefinition = new GeospatialIndex(dotPath); indexDefinition.withBits(index.bits()); indexDefinition.withMin(index.min()).withMax(index.max()); if (!index.useGeneratedName()) { indexDefinition.named(pathAwareIndexName(index.name(), dotPath, persistentProperty)); } indexDefinition.typed(index.type()).withBucketSize(index.bucketSize()).withAdditionalField(index.additionalField()); return new IndexDefinitionHolder(dotPath, indexDefinition, collection); }
/** * Value object to represent an {@link Address}. * * @author Oliver Gierke */ @Value public static class Address { String street, city, zip; @GeoSpatialIndexed(type = GEO_2DSPHERE) Point location; /* * (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return String.format("%s, %s %s", street, zip, city); } } }
@Value public static class Address { String street, city, zip; @GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE) Point location; } }
/** * Value object to represent an {@link Address}. * * @author Oliver Gierke */ @Value public class Address { private final String street, city, zip; private final @GeoSpatialIndexed Point location; }
@JsonIgnore private final @GeoSpatialIndexed Point location; private String state;