From 5b2b1f7d52fb51adecd683c790c8b464d318b375 Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Fri, 1 Dec 2023 14:45:47 +0100 Subject: [PATCH] Refactor code: Remove unnecessary 'this' keyword The 'this' keyword was removed from various lines in the code for simplification. The keyword was redundant and does not impact functionality, thus improving code readability. All implementation and behaviour remains the same. --- .../dlsc/phonenumberfx/PhoneNumberField.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java b/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java index 92d1485..ba77ff8 100644 --- a/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java +++ b/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java @@ -130,10 +130,10 @@ protected void layoutChildren(double x, double y, double w, double h) { Bounds bounds = displayNode.getBoundsInParent(); // use the same bounds for the globe that were computed for the button cell - this.globeButton.resizeRelocate(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); - this.globeButton.setVisible(getSkinnable().getValue() == null); - this.globeButton.setManaged(getSkinnable().getValue() == null); - this.globeButton.toFront(); + globeButton.resizeRelocate(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); + globeButton.setVisible(getSkinnable().getValue() == null); + globeButton.setManaged(getSkinnable().getValue() == null); + globeButton.toFront(); } }; } @@ -1007,10 +1007,10 @@ private String countryName() { private final class PhoneNumberFormatter implements UnaryOperator { private PhoneNumberFormatter() { - PhoneNumberField.this.setTextFormatter(new TextFormatter<>(this)); - PhoneNumberField.this.addEventHandler(KeyEvent.KEY_PRESSED, e -> { + setTextFormatter(new TextFormatter<>(this)); + addEventHandler(KeyEvent.KEY_PRESSED, e -> { if (e.getCode() == KeyCode.BACK_SPACE - && (PhoneNumberField.this.getText() == null || PhoneNumberField.this.getText().isEmpty()) + && (getText() == null || getText().isEmpty()) && getSelectedCountry() != null && !getDisableCountryDropdown()) { @@ -1072,7 +1072,7 @@ private void resolveCountry(TextFormatter.Change change) { setSelectedCountry(country); if (!isCountryCodeVisible()) { Platform.runLater(() -> { - PhoneNumberField.this.setText(Optional.ofNullable(country.defaultAreaCode()).map(String::valueOf).orElse("")); + setText(Optional.ofNullable(country.defaultAreaCode()).map(String::valueOf).orElse("")); change.setText(""); change.setCaretPosition(0); change.setAnchor(0); @@ -1129,8 +1129,8 @@ private void setFormattedPhoneNumber(String newRawPhoneNumber) { try { selfUpdate = true; String formattedPhoneNumber = doFormat(newRawPhoneNumber, getSelectedCountry()); - PhoneNumberField.this.setText(formattedPhoneNumber); - PhoneNumberField.this.positionCaret(formattedPhoneNumber.length()); + setText(formattedPhoneNumber); + positionCaret(formattedPhoneNumber.length()); } finally { selfUpdate = false; }