Use Java 14 switch expressions (#82178)

JEP 361[https://openjdk.java.net/jeps/361] added support for switch expressions
which can be much more terse and less error-prone than switch statements.

Another useful feature of switch expressions is exhaustiveness: we can make
sure that an enum switch expression covers all the cases at compile time.
This commit is contained in:
Artem Prigoda 2022-01-10 09:53:35 +01:00 committed by GitHub
parent 35a79bc7d4
commit 0699c9351f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
720 changed files with 7813 additions and 13306 deletions

View file

@ -45,52 +45,36 @@ final class DateField {
static final String GET_SECONDS_METHOD = "getSeconds";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
switch (variable) {
case VALUE_VARIABLE:
return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case EMPTY_VARIABLE:
return new EmptyMemberValueSource(fieldData);
case LENGTH_VARIABLE:
return new CountMethodValueSource(fieldData);
default:
throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for date field [" + fieldName + "].");
}
return switch (variable) {
case VALUE_VARIABLE -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case EMPTY_VARIABLE -> new EmptyMemberValueSource(fieldData);
case LENGTH_VARIABLE -> new CountMethodValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for date field [" + fieldName + "]."
);
};
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
switch (method) {
case GETVALUE_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case ISEMPTY_METHOD:
return new EmptyMemberValueSource(fieldData);
case SIZE_METHOD:
return new CountMethodValueSource(fieldData);
case MINIMUM_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case MAXIMUM_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
case AVERAGE_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
case MEDIAN_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
case SUM_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
case COUNT_METHOD:
return new CountMethodValueSource(fieldData);
case GET_YEAR_METHOD:
return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.YEAR);
case GET_MONTH_METHOD:
return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MONTH);
case GET_DAY_OF_MONTH_METHOD:
return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.DAY_OF_MONTH);
case GET_HOUR_OF_DAY_METHOD:
return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.HOUR_OF_DAY);
case GET_MINUTES_METHOD:
return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MINUTE);
case GET_SECONDS_METHOD:
return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.SECOND);
default:
throw new IllegalArgumentException("Member method [" + method + "] does not exist for date field [" + fieldName + "].");
}
return switch (method) {
case GETVALUE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case ISEMPTY_METHOD -> new EmptyMemberValueSource(fieldData);
case SIZE_METHOD -> new CountMethodValueSource(fieldData);
case MINIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case MAXIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MAX);
case AVERAGE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.AVG);
case MEDIAN_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
case SUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.SUM);
case COUNT_METHOD -> new CountMethodValueSource(fieldData);
case GET_YEAR_METHOD -> new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.YEAR);
case GET_MONTH_METHOD -> new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MONTH);
case GET_DAY_OF_MONTH_METHOD -> new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.DAY_OF_MONTH);
case GET_HOUR_OF_DAY_METHOD -> new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.HOUR_OF_DAY);
case GET_MINUTES_METHOD -> new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MINUTE);
case GET_SECONDS_METHOD -> new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.SECOND);
default -> throw new IllegalArgumentException(
"Member method [" + method + "] does not exist for date field [" + fieldName + "]."
);
};
}
}

View file

@ -64,112 +64,154 @@ final class DateObject {
static final String GETYEAR_OF_ERA_METHOD = "getYearOfEra";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
switch (variable) {
case CENTURY_OF_ERA_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.YEAR_OF_ERA) / 100);
case DAY_OF_MONTH_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getDayOfMonth);
case DAY_OF_WEEK_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.getDayOfWeek().getValue());
case DAY_OF_YEAR_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getDayOfYear);
case ERA_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.ERA));
case HOUR_OF_DAY_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getHour);
case MILLIS_OF_DAY_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.MILLI_OF_DAY));
case MILLIS_OF_SECOND_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.MILLI_OF_SECOND));
case MINUTE_OF_DAY_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.MINUTE_OF_DAY));
case MINUTE_OF_HOUR_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getMinute);
case MONTH_OF_YEAR_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getMonthValue);
case SECOND_OF_DAY_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.SECOND_OF_DAY));
case SECOND_OF_MINUTE_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getSecond);
case WEEK_OF_WEEK_YEAR_VARIABLE:
return new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())
);
case WEEK_YEAR_VARIABLE:
return new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())
);
case YEAR_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getYear);
case YEAR_OF_CENTURY_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100);
case YEAR_OF_ERA_VARIABLE:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.YEAR_OF_ERA));
default:
throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for date object on field [" + fieldName + "]."
);
}
return switch (variable) {
case CENTURY_OF_ERA_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA) / 100
);
case DAY_OF_MONTH_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getDayOfMonth);
case DAY_OF_WEEK_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.getDayOfWeek().getValue()
);
case DAY_OF_YEAR_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getDayOfYear);
case ERA_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, zdt -> zdt.get(ChronoField.ERA));
case HOUR_OF_DAY_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getHour);
case MILLIS_OF_DAY_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.MILLI_OF_DAY)
);
case MILLIS_OF_SECOND_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.MILLI_OF_SECOND)
);
case MINUTE_OF_DAY_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.MINUTE_OF_DAY)
);
case MINUTE_OF_HOUR_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getMinute);
case MONTH_OF_YEAR_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getMonthValue);
case SECOND_OF_DAY_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.SECOND_OF_DAY)
);
case SECOND_OF_MINUTE_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getSecond);
case WEEK_OF_WEEK_YEAR_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())
);
case WEEK_YEAR_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())
);
case YEAR_VARIABLE -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, variable, ZonedDateTime::getYear);
case YEAR_OF_CENTURY_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100
);
case YEAR_OF_ERA_VARIABLE -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
variable,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA)
);
default -> throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for date object on field [" + fieldName + "]."
);
};
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
switch (method) {
case GETCENTURY_OF_ERA_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.YEAR_OF_ERA) / 100);
case GETDAY_OF_MONTH_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getDayOfMonth);
case GETDAY_OF_WEEK_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.getDayOfWeek().getValue());
case GETDAY_OF_YEAR_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getDayOfYear);
case GETERA_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.ERA));
case GETHOUR_OF_DAY_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getHour);
case GETMILLIS_OF_DAY_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.MILLI_OF_DAY));
case GETMILLIS_OF_SECOND_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.MILLI_OF_SECOND));
case GETMINUTE_OF_DAY_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.MINUTE_OF_DAY));
case GETMINUTE_OF_HOUR_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getMinute);
case GETMONTH_OF_YEAR_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getMonthValue);
case GETSECOND_OF_DAY_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.SECOND_OF_DAY));
case GETSECOND_OF_MINUTE_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getSecond);
case GETWEEK_OF_WEEK_YEAR_METHOD:
return new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())
);
case GETWEEK_YEAR_METHOD:
return new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())
);
case GETYEAR_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getYear);
case GETYEAR_OF_CENTURY_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100);
case GETYEAR_OF_ERA_METHOD:
return new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.YEAR_OF_ERA));
default:
throw new IllegalArgumentException(
"Member method [" + method + "] does not exist for date object on field [" + fieldName + "]."
);
}
return switch (method) {
case GETCENTURY_OF_ERA_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA) / 100
);
case GETDAY_OF_MONTH_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getDayOfMonth);
case GETDAY_OF_WEEK_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.getDayOfWeek().getValue()
);
case GETDAY_OF_YEAR_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getDayOfYear);
case GETERA_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, zdt -> zdt.get(ChronoField.ERA));
case GETHOUR_OF_DAY_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getHour);
case GETMILLIS_OF_DAY_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.MILLI_OF_DAY)
);
case GETMILLIS_OF_SECOND_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.MILLI_OF_SECOND)
);
case GETMINUTE_OF_DAY_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.MINUTE_OF_DAY)
);
case GETMINUTE_OF_HOUR_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getMinute);
case GETMONTH_OF_YEAR_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getMonthValue);
case GETSECOND_OF_DAY_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.SECOND_OF_DAY)
);
case GETSECOND_OF_MINUTE_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getSecond);
case GETWEEK_OF_WEEK_YEAR_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())
);
case GETWEEK_YEAR_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())
);
case GETYEAR_METHOD -> new DateObjectValueSource(fieldData, MultiValueMode.MIN, method, ZonedDateTime::getYear);
case GETYEAR_OF_CENTURY_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA) % 100
);
case GETYEAR_OF_ERA_METHOD -> new DateObjectValueSource(
fieldData,
MultiValueMode.MIN,
method,
zdt -> zdt.get(ChronoField.YEAR_OF_ERA)
);
default -> throw new IllegalArgumentException(
"Member method [" + method + "] does not exist for date object on field [" + fieldName + "]."
);
};
}
}

View file

@ -29,28 +29,24 @@ final class GeoField {
static final String GETLON_METHOD = "getLon";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
switch (variable) {
case EMPTY_VARIABLE:
return new GeoEmptyValueSource(fieldData);
case LAT_VARIABLE:
return new GeoLatitudeValueSource(fieldData);
case LON_VARIABLE:
return new GeoLongitudeValueSource(fieldData);
default:
throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for geo field [" + fieldName + "].");
}
return switch (variable) {
case EMPTY_VARIABLE -> new GeoEmptyValueSource(fieldData);
case LAT_VARIABLE -> new GeoLatitudeValueSource(fieldData);
case LON_VARIABLE -> new GeoLongitudeValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for geo field [" + fieldName + "]."
);
};
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
switch (method) {
case ISEMPTY_METHOD:
return new GeoEmptyValueSource(fieldData);
case GETLAT_METHOD:
return new GeoLatitudeValueSource(fieldData);
case GETLON_METHOD:
return new GeoLongitudeValueSource(fieldData);
default:
throw new IllegalArgumentException("Member method [" + method + "] does not exist for geo field [" + fieldName + "].");
}
return switch (method) {
case ISEMPTY_METHOD -> new GeoEmptyValueSource(fieldData);
case GETLAT_METHOD -> new GeoLatitudeValueSource(fieldData);
case GETLON_METHOD -> new GeoLongitudeValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member method [" + method + "] does not exist for geo field [" + fieldName + "]."
);
};
}
}

View file

@ -36,42 +36,30 @@ final class NumericField {
static final String COUNT_METHOD = "count";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
switch (variable) {
case VALUE_VARIABLE:
return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case EMPTY_VARIABLE:
return new EmptyMemberValueSource(fieldData);
case LENGTH_VARIABLE:
return new CountMethodValueSource(fieldData);
default:
throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for " + "numeric field [" + fieldName + "]."
);
}
return switch (variable) {
case VALUE_VARIABLE -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case EMPTY_VARIABLE -> new EmptyMemberValueSource(fieldData);
case LENGTH_VARIABLE -> new CountMethodValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member variable [" + variable + "] does not exist for " + "numeric field [" + fieldName + "]."
);
};
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
switch (method) {
case GETVALUE_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case ISEMPTY_METHOD:
return new EmptyMemberValueSource(fieldData);
case SIZE_METHOD:
return new CountMethodValueSource(fieldData);
case MINIMUM_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case MAXIMUM_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
case AVERAGE_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
case MEDIAN_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
case SUM_METHOD:
return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
case COUNT_METHOD:
return new CountMethodValueSource(fieldData);
default:
throw new IllegalArgumentException("Member method [" + method + "] does not exist for numeric field [" + fieldName + "].");
}
return switch (method) {
case GETVALUE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case ISEMPTY_METHOD -> new EmptyMemberValueSource(fieldData);
case SIZE_METHOD -> new CountMethodValueSource(fieldData);
case MINIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MIN);
case MAXIMUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MAX);
case AVERAGE_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.AVG);
case MEDIAN_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
case SUM_METHOD -> new FieldDataValueSource(fieldData, MultiValueMode.SUM);
case COUNT_METHOD -> new CountMethodValueSource(fieldData);
default -> throw new IllegalArgumentException(
"Member method [" + method + "] does not exist for numeric field [" + fieldName + "]."
);
};
}
}