-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decompress services and service usage into separate services + classes
- Loading branch information
1 parent
687fcdc
commit 6049876
Showing
10 changed files
with
470 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/java/io/github/lucasstarsz/fxdex/service/DefaultUIService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.github.lucasstarsz.fxdex.service; | ||
|
||
public class DefaultUIService implements UiService { | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/io/github/lucasstarsz/fxdex/service/DexRequestOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.github.lucasstarsz.fxdex.service; | ||
|
||
import io.github.lucasstarsz.fxdex.misc.ApiLinks; | ||
import javafx.beans.property.Property; | ||
import javafx.beans.property.SimpleObjectProperty; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.http.HttpRequest; | ||
|
||
import static io.github.lucasstarsz.fxdex.misc.ApiConversionTables.PokedexNameToIdMap; | ||
|
||
public class DexRequestOptions { | ||
private final Property<URI> linkProperty; | ||
|
||
public DexRequestOptions() throws URISyntaxException { | ||
this(DexRequestType.Default, null); | ||
} | ||
|
||
public DexRequestOptions(DexRequestType requestType, String link) throws URISyntaxException { | ||
linkProperty = new SimpleObjectProperty<>(); | ||
|
||
switch (requestType) { | ||
case DexEntry -> setLinkAsDexEntry(link); | ||
case DexList -> setLinkAsDexList(link); | ||
default -> linkProperty.setValue(new URI(ApiLinks.AllDexesUrl)); | ||
} | ||
} | ||
|
||
public Property<URI> linkProperty() { | ||
return new SimpleObjectProperty<>(linkProperty.getValue()); | ||
} | ||
|
||
private void setLinkAsDexEntry(String dexEntry) throws URISyntaxException { | ||
linkProperty.setValue(new URI(ApiLinks.DexEntryUrl + dexEntry.toLowerCase() + '/')); | ||
} | ||
|
||
private void setLinkAsDexList(String pokedex) throws URISyntaxException { | ||
linkProperty.setValue(new URI(ApiLinks.DexUrl + PokedexNameToIdMap.get(pokedex.toLowerCase()) + '/')); | ||
} | ||
|
||
public HttpRequest buildGetRequest(HttpService httpService) { | ||
return HttpRequest.newBuilder(httpService.getDefaultDexRequest(), (n, v) -> true) | ||
.uri(linkProperty.getValue()) | ||
.GET() | ||
.build(); | ||
} | ||
|
||
public static DexRequestOptions defaultOptions() throws URISyntaxException { | ||
return new DexRequestOptions(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/io/github/lucasstarsz/fxdex/service/DexRequestType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.github.lucasstarsz.fxdex.service; | ||
|
||
public enum DexRequestType { | ||
Default, | ||
DexEntry, | ||
DexList | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.