Skip to content

Instantly share code, notes, and snippets.

@dev-aritra
Created November 16, 2020 11:16
Show Gist options
  • Save dev-aritra/7dde7bbae88f210d4c1cdbb24155c744 to your computer and use it in GitHub Desktop.
Save dev-aritra/7dde7bbae88f210d4c1cdbb24155c744 to your computer and use it in GitHub Desktop.
@Document(collection = "stores")
public class StoreEntity {
@Id
private String id;
private final String name;
private final String zipCode;
private final GeoJSONPoint geoJSONPoint;
public StoreEntity(String name, String zipCode, GeoJSONPoint geoJSONPoint) {
this.name = name;
this.zipCode = zipCode;
this.geoJSONPoint = geoJSONPoint;
}
public static StoreEntity fromDomain(Store store) {
return new StoreEntity(
store.getName(),
store.getLocation().getZipCode(),
new GeoJSONPoint(List.of(store.getLocation().getLongitude(), store.getLocation().getLatitude())));
}
public Store toDomain() {
return new Store(id, name, new Location(zipCode, geoJSONPoint.getCoordinates().get(1), geoJSONPoint.getCoordinates().get(0)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment