Skip to content

Commit

Permalink
refactor: rename internal property i18n to datePickerI18n (#6328)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored May 28, 2024
1 parent 2446908 commit 937d0c6
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public class DateTimePicker

private final DateTimePickerDatePicker datePicker = new DateTimePickerDatePicker();
private final DateTimePickerTimePicker timePicker = new DateTimePickerTimePicker();
private DatePickerI18n i18n;
private DatePickerI18n datePickerI18n;

private DateTimePickerI18n dateTimePickerI18n;
private DateTimePickerI18n i18n;
private Locale locale;

private final static SerializableFunction<String, LocalDateTime> PARSER = s -> {
Expand Down Expand Up @@ -450,12 +450,11 @@ public void setTimeLabel(String timeLabel) {
* the value to be used as part of date picker aria-label.
*/
public void setDateAriaLabel(String dateLabel) {
if (dateTimePickerI18n == null) {
dateTimePickerI18n = new DateTimePickerI18n();
if (i18n == null) {
i18n = new DateTimePickerI18n();
}
dateTimePickerI18n.setDateLabel(dateLabel);
getElement().setPropertyJson("i18n",
JsonSerializer.toJson(dateTimePickerI18n));
i18n.setDateLabel(dateLabel);
getElement().setPropertyJson("i18n", JsonSerializer.toJson(i18n));
}

/**
Expand All @@ -468,10 +467,10 @@ public void setDateAriaLabel(String dateLabel) {
* @return an optional label or an empty optional if no label has been set
*/
public Optional<String> getDateAriaLabel() {
if (dateTimePickerI18n == null) {
if (i18n == null) {
return Optional.empty();
}
return Optional.ofNullable(dateTimePickerI18n.getDateLabel());
return Optional.ofNullable(i18n.getDateLabel());
}

/**
Expand All @@ -485,12 +484,11 @@ public Optional<String> getDateAriaLabel() {
* the value to be used as part of time picker aria-label.
*/
public void setTimeAriaLabel(String timeLabel) {
if (dateTimePickerI18n == null) {
dateTimePickerI18n = new DateTimePickerI18n();
if (i18n == null) {
i18n = new DateTimePickerI18n();
}
dateTimePickerI18n.setTimeLabel(timeLabel);
getElement().setPropertyJson("i18n",
JsonSerializer.toJson(dateTimePickerI18n));
i18n.setTimeLabel(timeLabel);
getElement().setPropertyJson("i18n", JsonSerializer.toJson(i18n));
}

/**
Expand All @@ -503,10 +501,10 @@ public void setTimeAriaLabel(String timeLabel) {
* @return an optional label or an empty optional if no label has been set
*/
public Optional<String> getTimeAriaLabel() {
if (dateTimePickerI18n == null) {
if (i18n == null) {
return Optional.empty();
}
return Optional.ofNullable(dateTimePickerI18n.getTimeLabel());
return Optional.ofNullable(i18n.getTimeLabel());
}

/**
Expand Down Expand Up @@ -603,7 +601,7 @@ public Duration getStep() {
* Set true to display ISO-8601 week numbers in the calendar.
* <p>
* Note that displaying of week numbers is only supported when
* i18n.firstDayOfWeek is 1 (Monday).
* datePickerI18n.firstDayOfWeek is 1 (Monday).
*
* @param weekNumbersVisible
* the boolean value to set
Expand Down Expand Up @@ -873,7 +871,7 @@ public LocalDateTime getMax() {
* properties weren't set.
*/
public DatePickerI18n getDatePickerI18n() {
return i18n;
return datePickerI18n;
}

/**
Expand All @@ -886,7 +884,7 @@ public DatePickerI18n getDatePickerI18n() {
public void setDatePickerI18n(DatePickerI18n i18n) {
Objects.requireNonNull(i18n,
"The i18n properties object should not be null");
this.i18n = i18n;
this.datePickerI18n = i18n;
datePicker.setI18n(i18n);
}

Expand Down

0 comments on commit 937d0c6

Please sign in to comment.