Sort Ephemeris config parameter options (#1681)

Fixes #1663

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2020-10-02 08:19:02 +02:00 committed by GitHub
parent 9739271b52
commit b62d494bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ import java.time.format.TextStyle;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@ -112,12 +113,21 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
final Properties properties = new Properties();
properties.load(stream);
properties.forEach(this::parseProperty);
sortByLabel(countries);
regions.values().forEach(this::sortByLabel);
cities.values().forEach(this::sortByLabel);
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
logger.warn("The resource '{}' could not be loaded properly! ConfigDescription options are not available.",
JOLLYDAY_COUNTRY_DESCRIPTIONS, e);
}
}
private void sortByLabel(List<ParameterOption> parameterOptions) {
Collections.sort(parameterOptions,
(ParameterOption po1, ParameterOption po2) -> po1.getLabel().compareTo(po2.getLabel()));
}
@Activate
protected void activate(Map<String, Object> config) {
modified(config);