Created
November 16, 2020 11:16
-
-
Save dev-aritra/7dde7bbae88f210d4c1cdbb24155c744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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