Skip to content

Commit b669aed

Browse files
javier-godoypaodb
authored andcommitted
refactor: use lombok extension mechanism
1 parent 39cc4aa commit b669aed

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.util.ArrayList;
4747
import java.util.List;
4848
import java.util.concurrent.CompletableFuture;
49+
import lombok.experimental.ExtensionMethod;
4950
import org.apache.commons.lang3.StringUtils;
5051

5152
@SuppressWarnings("serial")
@@ -54,6 +55,7 @@
5455
@NpmPackage(value = "@flowingcode/google-map", version = "3.9.0")
5556
@NpmPackage(value = "@googlemaps/markerclusterer", version = "2.0.8")
5657
@JsModule("./googlemaps/geolocation.js")
58+
@ExtensionMethod(value = JsonMigration.class, suppressBaseMethods = true)
5759
public class GoogleMap extends Component implements HasSize {
5860

5961
private Integer trackLocationId = null;
@@ -519,7 +521,7 @@ public Registration addClickListener(ComponentEventListener<GoogleMapClickEvent>
519521
DomListenerRegistration registration =
520522
getElement()
521523
.addEventListener("google-map-click", ev -> {
522-
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
524+
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
523525
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
524526
}).addEventData("event.detail.latLng");
525527
return registration::remove;
@@ -531,7 +533,7 @@ public Registration addRightClickListener(ComponentEventListener<GoogleMapClickE
531533
DomListenerRegistration registration =
532534
getElement()
533535
.addEventListener("google-map-rightclick", ev -> {
534-
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
536+
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
535537
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
536538
}).addEventData("event.detail.latLng");
537539
return registration::remove;
@@ -768,7 +770,7 @@ public Registration addGoogleMapBoundsChangedListener(
768770
DomListenerRegistration registration =
769771
getElement().addEventListener("google-map-bounds_changed", ev -> {
770772
listener.onComponentEvent(new GoogleMapBoundsChangedEvent(this, true,
771-
new LatLonBounds(JsonMigration.getEventData(ev).get("event.detail"))));
773+
new LatLonBounds(ev.getEventData().get("event.detail"))));
772774
}).debounce(1000, DebouncePhase.TRAILING).addEventData("event.detail");
773775
return registration::remove;
774776
}
@@ -804,7 +806,7 @@ public void addCustomControls(CustomControl... customControls) {
804806
customControl.getControlButton().getElement().setAttribute("slot", "customControlSlot_" + i);
805807
getElement().appendChild(customControl.getControlButton().getElement());
806808
}
807-
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
809+
getElement().setPropertyJson("customControls", jsonArray);
808810
}
809811

810812
/**
@@ -823,7 +825,7 @@ public void setCustomControls(CustomControl... customControls) {
823825
getElement().appendChild(customControl.getControlButton().getElement());
824826
this.customControls.add(customControl);
825827
}
826-
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
828+
getElement().setPropertyJson("customControls", jsonArray);
827829
});
828830
}
829831

@@ -925,6 +927,6 @@ public void setMapStyle(MapStyle... mapStyles) {
925927
MapStyle mapStyle = mapStyles[i];
926928
jsonArray.set(i, mapStyle.getJson());
927929
}
928-
JsonMigration.setPropertyJson(getElement(), "styles", jsonArray);
930+
getElement().setPropertyJson("styles", jsonArray);
929931
}
930932
}

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMapMarker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import com.vaadin.flow.shared.Registration;
3636
import elemental.json.JsonObject;
3737
import elemental.json.JsonValue;
38+
import lombok.experimental.ExtensionMethod;
3839

3940
/** The class representing a marker of the Google Map. */
4041
@SuppressWarnings("serial")
4142
@Tag("google-map-marker")
4243
@JsModule("@flowingcode/google-map/google-map-marker.js")
4344
@NpmPackage(value = "@flowingcode/google-map", version = "3.9.0")
4445
@NpmPackage(value = "@googlemaps/markerclusterer", version = "2.0.8")
46+
@ExtensionMethod(value = JsonMigration.class, suppressBaseMethods = true)
4547
public class GoogleMapMarker extends Component {
4648

4749
private static long idCounter = 0;
@@ -194,7 +196,7 @@ public void setIconUrl(String iconUrl) {
194196
* @param icon the icon image of the marker
195197
*/
196198
public void setIcon(GoogleMapIcon icon) {
197-
JsonMigration.setPropertyJson(getElement(), "icon", icon.getJson());
199+
this.getElement().setPropertyJson("icon", icon.getJson());
198200
}
199201

200202
/**
@@ -204,7 +206,7 @@ public void setIcon(GoogleMapIcon icon) {
204206
* @param label the new marker's label
205207
*/
206208
public void setLabel(MarkerLabel label) {
207-
JsonMigration.setPropertyJson(getElement(), "label", label.getJson());
209+
this.getElement().setPropertyJson("label", label.getJson());
208210
}
209211

210212
/**

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMapPoly.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import elemental.json.JsonObject;
3636
import elemental.json.JsonValue;
3737
import java.util.List;
38+
import lombok.experimental.ExtensionMethod;
3839

3940
@SuppressWarnings("serial")
4041
@Tag("google-map-poly")
4142
@JsModule("@flowingcode/google-map/google-map-poly.js")
4243
@JsModule("@flowingcode/google-map/google-map-point.js")
4344
@NpmPackage(value = "@flowingcode/google-map", version = "3.9.0")
4445
@NpmPackage(value = "@googlemaps/markerclusterer", version = "2.0.8")
46+
@ExtensionMethod(value = JsonMigration.class, suppressBaseMethods = true)
4547
public abstract class GoogleMapPoly extends Component {
4648

4749
private static final double DEFAULT_FILL_OPACITY = 0.5d;
@@ -192,7 +194,7 @@ public void setIcons(Icon... icons) {
192194
for (int i = 0; i < icons.length; i++) {
193195
jsonArray.set(i, icons[i].getJson());
194196
}
195-
JsonMigration.setPropertyJson(getElement(), "icons", jsonArray);
197+
getElement().setPropertyJson("icons", jsonArray);
196198
}
197199

198200
/**
@@ -205,7 +207,7 @@ public void setIcons(IconSequence... icons) {
205207
for (int i = 0; i < icons.length; i++) {
206208
jsonArray.set(i, icons[i].getJson());
207209
}
208-
JsonMigration.setPropertyJson(getElement(), "icons", jsonArray);
210+
getElement().setPropertyJson("icons", jsonArray);
209211
}
210212

211213
}

0 commit comments

Comments
 (0)