diff --git a/src/main/java/eu/m724/wtapi/provider/Providers.java b/src/main/java/eu/m724/wtapi/provider/Providers.java
index 9aea931..f6ae929 100644
--- a/src/main/java/eu/m724/wtapi/provider/Providers.java
+++ b/src/main/java/eu/m724/wtapi/provider/Providers.java
@@ -1,5 +1,6 @@
package eu.m724.wtapi.provider;
+import eu.m724.wtapi.provider.exception.NoSuchProviderException;
import eu.m724.wtapi.provider.thunder.ThunderProvider;
import eu.m724.wtapi.provider.thunder.impl.blitzortung.BlitzortungProvider;
import eu.m724.wtapi.provider.twilight.impl.approximate.ApproximateTwilightTimeProvider;
@@ -19,12 +20,12 @@ public class Providers {
* @throws NoSuchProviderException If invalid provider name
*/
public static ThunderProvider getThunderProvider(String name, String apiKey) {
- switch (name.toLowerCase()) {
- case "blitzortung" -> new BlitzortungProvider();
- }
-
- throw new NoSuchProviderException(name);
- }
+ return switch (name.toLowerCase()) {
+ case "blitzortung", "lightningmaps" -> new BlitzortungProvider();
+ default -> throw new NoSuchProviderException(name);
+ };
+
+ }
/**
* Gets a weather provider by name.
@@ -36,12 +37,12 @@ public class Providers {
* @throws NoSuchProviderException If invalid provider name
*/
public static WeatherProvider getWeatherProvider(String name, String apiKey) {
- switch (name.toLowerCase()) {
- case "openmeteo" -> new OpenMeteoProvider();
- }
-
- throw new NoSuchProviderException(name);
- }
+ return switch (name.toLowerCase()) {
+ case "openmeteo", "open-meteo" -> new OpenMeteoProvider();
+ default -> throw new NoSuchProviderException(name);
+ };
+
+ }
/**
* Gets a twilight time provider by name.
@@ -53,16 +54,9 @@ public class Providers {
* @throws NoSuchProviderException If invalid provider name
*/
public static TwilightTimeProvider getTwilightTimeProvider(String name, String apiKey) {
- switch (name.toLowerCase()) {
+ return switch (name.toLowerCase()) {
case "approximate" -> new ApproximateTwilightTimeProvider();
- }
-
- throw new NoSuchProviderException(name);
- }
-
- public static class NoSuchProviderException extends RuntimeException {
- public NoSuchProviderException(String provider) {
- super(provider);
- }
+ default -> throw new NoSuchProviderException(name);
+ };
}
}
diff --git a/src/main/java/eu/m724/wtapi/provider/exception/NoSuchProviderException.java b/src/main/java/eu/m724/wtapi/provider/exception/NoSuchProviderException.java
new file mode 100644
index 0000000..6678247
--- /dev/null
+++ b/src/main/java/eu/m724/wtapi/provider/exception/NoSuchProviderException.java
@@ -0,0 +1,7 @@
+package eu.m724.wtapi.provider.exception;
+
+public class NoSuchProviderException extends RuntimeException {
+ public NoSuchProviderException(String provider) {
+ super("No such provider: " + provider);
+ }
+}