reorg
This commit is contained in:
parent
c0b171d89b
commit
7d6e0e1077
17 changed files with 85 additions and 15 deletions
17
.classpath
17
.classpath
|
@ -36,5 +36,22 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
11
.project
11
.project
|
@ -20,4 +20,15 @@
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1718972143313</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
29
src/main/java/eu/m724/wtapi/provider/Providers.java
Normal file
29
src/main/java/eu/m724/wtapi/provider/Providers.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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.weather.WeatherProvider;
|
||||||
|
import eu.m724.wtapi.provider.weather.impl.openweathermap.OpenWeatherMapProvider;
|
||||||
|
|
||||||
|
public class Providers {
|
||||||
|
|
||||||
|
public static ThunderProvider getThunderProvider(String name, String apiKey) throws NoSuchProviderException {
|
||||||
|
switch (name.toLowerCase()) {
|
||||||
|
case "blitzortung":
|
||||||
|
return new BlitzortungProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NoSuchProviderException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WeatherProvider getWeatherProvider(String name, String apiKey) throws NoSuchProviderException {
|
||||||
|
switch (name.toLowerCase()) {
|
||||||
|
case "openweathermap":
|
||||||
|
return new OpenWeatherMapProvider(apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NoSuchProviderException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package eu.m724.wtapi.provider.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* thrown when there's no known provider with that name
|
||||||
|
*/
|
||||||
|
public class NoSuchProviderException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2740598348303023762L;
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.thunder;
|
package eu.m724.wtapi.provider.thunder;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.thunder.impl.blitzortung;
|
package eu.m724.wtapi.provider.thunder.impl.blitzortung;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
@ -6,7 +6,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||||
import eu.m724.wtapi.thunder.ThunderProvider;
|
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||||
|
|
||||||
public class BlitzortungProvider extends ThunderProvider {
|
public class BlitzortungProvider extends ThunderProvider {
|
||||||
BlitzortungWebsocketClient websocketClient = new BlitzortungWebsocketClient(this);
|
BlitzortungWebsocketClient websocketClient = new BlitzortungWebsocketClient(this);
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.thunder.impl.blitzortung;
|
package eu.m724.wtapi.provider.thunder.impl.blitzortung;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.thunder.impl.blitzortung;
|
package eu.m724.wtapi.provider.thunder.impl.blitzortung;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.provider;
|
package eu.m724.wtapi.provider.weather;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.provider.impl.openweathermap;
|
package eu.m724.wtapi.provider.weather.impl.openweathermap;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.m724.wtapi.provider.impl.openweathermap;
|
package eu.m724.wtapi.provider.weather.impl.openweathermap;
|
||||||
|
|
||||||
import java.net.ProxySelector;
|
import java.net.ProxySelector;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -15,11 +15,11 @@ import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.object.Weather;
|
import eu.m724.wtapi.object.Weather;
|
||||||
import eu.m724.wtapi.provider.WeatherProvider;
|
|
||||||
import eu.m724.wtapi.provider.exception.AuthorizationException;
|
import eu.m724.wtapi.provider.exception.AuthorizationException;
|
||||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||||
import eu.m724.wtapi.provider.exception.QuotaExceededException;
|
import eu.m724.wtapi.provider.exception.QuotaExceededException;
|
||||||
import eu.m724.wtapi.provider.exception.ServerProviderException;
|
import eu.m724.wtapi.provider.exception.ServerProviderException;
|
||||||
|
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||||
|
|
||||||
public class OpenWeatherMapProvider extends WeatherProvider {
|
public class OpenWeatherMapProvider extends WeatherProvider {
|
||||||
private String apiKey;
|
private String apiKey;
|
|
@ -5,7 +5,8 @@ import java.util.ArrayList;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.thunder.impl.blitzortung.BlitzortungProvider;
|
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||||
|
import eu.m724.wtapi.provider.thunder.impl.blitzortung.BlitzortungProvider;
|
||||||
|
|
||||||
public class BlitzortungTest {
|
public class BlitzortungTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -6,7 +6,8 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||||
import eu.m724.wtapi.thunder.impl.blitzortung.TimedStrike;
|
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||||
|
import eu.m724.wtapi.provider.thunder.impl.blitzortung.TimedStrike;
|
||||||
|
|
||||||
public class MockThunderProvider extends ThunderProvider {
|
public class MockThunderProvider extends ThunderProvider {
|
||||||
ArrayList<Consumer<Coordinates>> strikeHandlers = new ArrayList<>();
|
ArrayList<Consumer<Coordinates>> strikeHandlers = new ArrayList<>();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
|
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||||
|
|
||||||
public class ThunderProviderTest {
|
public class ThunderProviderTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -3,10 +3,10 @@ package eu.m724.wtapi.weather;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.object.Weather;
|
import eu.m724.wtapi.object.Weather;
|
||||||
import eu.m724.wtapi.provider.WeatherProvider;
|
|
||||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||||
import eu.m724.wtapi.provider.exception.QuotaExceededException;
|
import eu.m724.wtapi.provider.exception.QuotaExceededException;
|
||||||
import eu.m724.wtapi.provider.exception.ServerProviderException;
|
import eu.m724.wtapi.provider.exception.ServerProviderException;
|
||||||
|
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||||
|
|
||||||
public class MockWeatherProvider extends WeatherProvider {
|
public class MockWeatherProvider extends WeatherProvider {
|
||||||
private boolean faulty;
|
private boolean faulty;
|
||||||
|
|
|
@ -9,8 +9,8 @@ import org.junit.Test;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.object.Weather;
|
import eu.m724.wtapi.object.Weather;
|
||||||
import eu.m724.wtapi.provider.WeatherProvider;
|
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||||
import eu.m724.wtapi.provider.impl.openweathermap.OpenWeatherMapProvider;
|
import eu.m724.wtapi.provider.weather.impl.openweathermap.OpenWeatherMapProvider;
|
||||||
|
|
||||||
public class OpenWeatherMapTest {
|
public class OpenWeatherMapTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -12,9 +12,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.object.Weather;
|
import eu.m724.wtapi.object.Weather;
|
||||||
import eu.m724.wtapi.provider.WeatherProvider;
|
|
||||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||||
import eu.m724.wtapi.provider.exception.QuotaExceededException;
|
import eu.m724.wtapi.provider.exception.QuotaExceededException;
|
||||||
|
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||||
|
|
||||||
public class ProviderTest {
|
public class ProviderTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue