diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index b1838ce..df3ff67 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,9 +1,5 @@ name: Release PokeAPI -env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - on: push: tags: @@ -48,7 +44,7 @@ jobs: - name: Build .jar run: sh gradlew build - + - name: Create Release if: ${{ success() }} id: create_release @@ -60,26 +56,3 @@ jobs: body: ${{steps.build_changelog.outputs.changelog}} artifacts: "${{ github.workspace }}/build/libs/pokeapi-${{ env.PROJECT_VERSION }}.jar" makeLatest: "latest" - - publish: - name: Publish PokeAPI - runs-on: ubuntu-latest - needs: - - release - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Publish PokeAPI - run: sh gradlew build - - - name: Publish PokeAPI - if: ${{ success() }} - run: sh gradlew publish diff --git a/.github/workflows/publish_maven_central.yml b/.github/workflows/publish_maven_central.yml new file mode 100644 index 0000000..73ee147 --- /dev/null +++ b/.github/workflows/publish_maven_central.yml @@ -0,0 +1,31 @@ +name : Publish PokeAPI + +env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + +on: + release: + types: [created] + +jobs: + publish: + name: Publish PokeAPI + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Publish PokeAPI + run: sh gradlew build + + - name: Publish PokeAPI + if: ${{ success() }} + run: sh gradlew publish diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index b1077fb..fdfef61 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,13 @@ + + + + - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index f49e936..8cbc8f9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,31 +1,26 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.JvmTarget val artifact = "pokeapi" val projectName = "PokeApi" val projectDocUrl = "https://tykok.github.io/PokeAPI-Kotlin/" -val sonarSnapshotUri = "https://s01.oss.sonatype.org/content/repositories/snapshots/" -val sonarReleaseUri = "https://s01.oss.sonatype.org/content/repositories/releases/" +val projectUrl = "https://github.com/Tykok/PokeAPI-Kotlin" +val mavenCentralPublishURI = uri("https://central.sonatype.com/api/v1/publisher/deployments/download/") description = "PokeApi is a simple library you can use to make request to get data about Pokémon." group = "fr.tykok" version = "1.0.0" -fun getUriSonar(): String = if (version.toString().endsWith("SNAPSHOT")) { - sonarSnapshotUri -} else { - sonarReleaseUri -} - plugins { + alias(libs.plugins.netResearchgateRelease) + alias(libs.plugins.dokka) + alias(libs.plugins.ktlint) `java-library` `maven-publish` + signing java - kotlin("jvm") version "1.7.10" + kotlin("jvm") version "2.0.0" application - signing - id("net.researchgate.release") version "3.0.2" - id("org.jetbrains.dokka") version "1.9.0" - id("org.jlleitschuh.gradle.ktlint") version "11.6.0" + jacoco } repositories { @@ -42,19 +37,35 @@ java { dependencies { testImplementation(kotlin("test")) - implementation("com.squareup.okhttp3:okhttp:4.10.0") - // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind - implementation("com.fasterxml.jackson.core:jackson-databind:2.0.1") - // https://mvnrepository.com/artifact/com.google.code.gson/gson - implementation("com.google.code.gson:gson:2.10.1") + implementation(libs.okhttp) + implementation(libs.jackson) + implementation(libs.gson) + + testImplementation(platform(libs.junitBom)) + testImplementation(libs.junitJupiter) + testRuntimeOnly(libs.junitPlatform) + testImplementation(libs.mockk) } tasks.test { useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + } } -tasks.withType { - kotlinOptions.jvmTarget = "1.8" +tasks.test { + finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run +} +tasks.jacocoTestReport { + dependsOn(tasks.test) // tests are required to run before generating the report +} + +kotlin { + compilerOptions { + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) + jvmTarget.set(JvmTarget.JVM_17) + } } tasks.create("getProjectVersion") { @@ -62,6 +73,7 @@ tasks.create("getProjectVersion") { logger.quiet("VERSION: $version") } } + tasks.register("dokkaHtmlJar") { dependsOn(tasks.dokkaHtml) from(tasks.dokkaHtml.flatMap { it.outputDirectory }) @@ -87,7 +99,15 @@ task("mkdocs-build") { } application { - mainClass.set("PokeApi") + mainClass.set("fr.tykok.pokeapi.PokeApi") +} + +sourceSets { + test { + kotlin { + srcDir("src/test/kotlin") + } + } } signing { @@ -96,35 +116,40 @@ signing { publishing { publications { - create("library") { - from(components["java"]) - } create("mavenJava") { + from(components["kotlin"]) + + groupId = groupId + artifactId = artifactId + version = version + pom { name.set(projectName) - description.set(description) - url.set(projectDocUrl) + url.set(projectUrl) + licenses { license { name.set("MIT License") - url.set("https://github.com/Tykok/PokeAPI-Kotlin/blob/main/LICENSE") + } + } + + developers { + developer { + name.set("Tykok") } } } } } + repositories { maven { - url = uri(getUriSonar()) - name = projectName - group = group - version = version.toString() - description = description + name = "sonatype" + url = mavenCentralPublishURI + credentials { - username = project.findProperty("ossrh.username") as String? - ?: System.getenv("OSSRH_USERNAME") - password = project.findProperty("ossrh.password") as String? - ?: System.getenv("OSSRH_PASSWORD") + username = project.findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME") + password = project.findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_PASSWORD") } } } diff --git a/docs/mkdocs-markdown/entities/berry.md b/docs/mkdocs-markdown/entities/berry.md index ef10a42..a3e0384 100644 --- a/docs/mkdocs-markdown/entities/berry.md +++ b/docs/mkdocs-markdown/entities/berry.md @@ -1,6 +1,6 @@ # Berry -The `Berry` entity is used to map data from `https://pokeapi.co/api/v2/berry/...`. +The `Berry` entities is used to map data from `https://pokeapi.co/api/v2/berry/...`. ![Berry](../img/berry.jpeg) diff --git a/docs/mkdocs-markdown/methods.md b/docs/mkdocs-markdown/methods.md index 1b64794..6ce28d8 100644 --- a/docs/mkdocs-markdown/methods.md +++ b/docs/mkdocs-markdown/methods.md @@ -3,13 +3,13 @@ To use the methods, you need to import `PokeApi` class. Next, you can use the `get` methods to fetch data from the [pokeapi.co][pokeapi]. -You need to give the entity type as a generic parameter to the `get()` methods. The available entity types are available -in the `fr.tykok.pokeapi.entity` package, all the documentation are given in the `API Resource` section of this website. +You need to give the entities type as a generic parameter to the `get()` methods. The available entities types are available +in the `fr.tykok.pokeapi.entities` package, all the documentation are given in the `API Resource` section of this website. All entities used to call a specific endpoint and is used to map the response of the endpoint. -Each entity are described in the entities section. +Each entities are described in the entities section. -Finally, you need to give an `id`, the `name`, or the `limit` of the list to get the entity or the list of entities +Finally, you need to give an `id`, the `name`, or the `limit` of the list to get the entities or the list of entities given in the generic parameter. All parameters for the `get()` method are described below. diff --git a/docs/site/entities/berry/index.html b/docs/site/entities/berry/index.html index 9e0cc05..fe11bac 100644 --- a/docs/site/entities/berry/index.html +++ b/docs/site/entities/berry/index.html @@ -9,20 +9,20 @@ - + - + - + @@ -95,7 +95,7 @@
@@ -111,11 +111,11 @@
- +

Berry

-

The Berry entity is used to map data from https://pokeapi.co/api/v2/berry/....

+

The Berry entities is used to map data from https://pokeapi.co/api/v2/berry/....

Berry

- +
- +
@@ -141,17 +141,17 @@

Berry

- + GitHub - - + + « Previous - - + + Next » - +
diff --git a/docs/site/methods/index.html b/docs/site/methods/index.html index f613d28..da8f0a6 100644 --- a/docs/site/methods/index.html +++ b/docs/site/methods/index.html @@ -9,20 +9,20 @@ - + - + - + @@ -101,7 +101,7 @@
@@ -116,15 +116,15 @@
- +

Methods

To use the methods, you need to import PokeApi class. Next, you can use the get methods to fetch data from the pokeapi.co.

-

You need to give the entity type as a generic parameter to the get() methods. The available entity types are available +

You need to give the entities type as a generic parameter to the get() methods. The available entities types are available in the fr.tykok.pokeapi.entity package, all the documentation are given in the API Resource section of this website.

All entities used to call a specific endpoint and is used to map the response of the endpoint. -Each entity are described in the entities section.

-

Finally, you need to give an id, the name, or the limit of the list to get the entity or the list of entities +Each entities are described in the entities section.

+

Finally, you need to give an id, the name, or the limit of the list to get the entities or the list of entities given in the generic parameter. All parameters for the get() method are described below.

With id of the pokemon

@@ -148,7 +148,7 @@

List of pokemon

pokemon from 10 to 20 with limit = 10 and offset = 10 (you start at the 10th pokemon and you get the 10 next).

val pokemonList = PokeApi.get<Pokemon>(limit = 10, offset = 10)
 
- +
- +
@@ -174,17 +174,17 @@

List of pokemon

- + GitHub - - + + « Previous - - + + Next » - +
diff --git a/gradle.properties b/gradle.properties index 7fc6f1f..e9631a8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,4 @@ kotlin.code.style=official +ossrhUsername=22ri/I/7 +ossrhPassword=FEeq/1eCi6y4Pz2StJ/+fi0poZPkevIeBpIHdpbeATxa +#12-Soleil&GPG diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..ab4fac9 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,24 @@ +[versions] +mockk = "1.13.11" +gson = "2.10" +jackson = "2.17.0" +okhttp = "4.10.0" +junitBom = "5.11.0-M1" + +[plugins] +netResearchgateRelease = { id = "net.researchgate.release", version = "3.0.2" } +dokka = { id = "org.jetbrains.dokka", version = "1.9.0" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.6.0" } + +[libraries] +junitBom = { module = "org.junit:junit-bom", version.ref = "junitBom" } +junitJupiter = { module = "org.junit.jupiter:junit-jupiter" } +junitPlatform = { module = "org.junit.platform:junit-platform-launcher" } +mockk = { module = "io.mockk:mockk", version.ref = "mockk" } +# https://mvnrepository.com/artifact/com.google.code.gson/gson +gson = { module = "com.google.code.gson:gson" , version.ref = "gson"} +# https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind +jackson = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson"} +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp"} + +[bundles] diff --git a/src/main/kotlin/PokeApi.kt b/src/main/kotlin/PokeApi.kt deleted file mode 100644 index 383fe96..0000000 --- a/src/main/kotlin/PokeApi.kt +++ /dev/null @@ -1,83 +0,0 @@ -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import entity.common.NamedApiResources -import exception.HttpBodyResponseException -import http.getEndpoint -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.Response - -/** - * PokeApi is a Kotlin wrapper for the PokeApi RESTful API. - * @author Tykok - * @version 1.0 - * @see PokeApi - * @see PokeApi Docs - */ -abstract class PokeApi { - companion object PokeApi { - private const val VERSION = "v2" - const val BASE_URL = "https://pokeapi.co/api/$VERSION" - - /** - * Get a resource by its id. - */ - inline fun get(id: Int): T = fetch(resource = id) - - /** - * Get a resource by its name. - */ - inline fun get(name: String): T = fetch(resource = name) - - /** - * Get a list of resources. - */ - inline fun get(limit: Int = 20, offset: Int = 20) = fetchAll( - limit, - offset - ) - - inline fun fetch(resource: Any? = ""): T = - parseResponse( - OkHttpClient().newCall( - createRequest("$BASE_URL/${getEndpoint()}/$resource") - ).execute() - ) - - inline fun fetch(fullUrl: String): T = - parseResponse( - OkHttpClient().newCall( - createRequest(fullUrl) - ).execute() - ) - - inline fun fetchAll(limit: Int, offset: Int): NamedApiResources { - return parseResponses( - OkHttpClient().newCall( - createRequest("$BASE_URL/${getEndpoint()}?offset=$offset&limit=$limit") - ).execute() - ) - } - - fun createRequest(url: String): Request = Request.Builder().url(url).build() - - inline fun parseResponse(response: Response): T { - try { - return Gson().fromJson(response.body?.string(), T::class.java) - } catch (e: Exception) { - throw HttpBodyResponseException(T::class) - } - } - - inline fun parseResponses(response: Response): NamedApiResources { - try { - return Gson().fromJson( - response.body?.string(), - object : TypeToken>() {}.type - ) - } catch (e: Exception) { - throw HttpBodyResponseException(T::class) - } - } - } -} diff --git a/src/main/kotlin/entity/pokemon/PokemonLocationArea.kt b/src/main/kotlin/entity/pokemon/PokemonLocationArea.kt deleted file mode 100644 index 941b8fc..0000000 --- a/src/main/kotlin/entity/pokemon/PokemonLocationArea.kt +++ /dev/null @@ -1,18 +0,0 @@ -package entity.pokemon - -import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.common.VersionEncounterDetail -import entity.locations.LocationArea - -class PokemonLocationArea( - @JsonProperty("location_area") - val locationArea: NamedApiResource, - - @JsonProperty("version_details") - val versionDetails: List -) { - override fun toString(): String { - return "PokemonLocationArea(locationArea=$locationArea, versionDetails=$versionDetails)" - } -} diff --git a/src/main/kotlin/entity/pokemon/TypePokemon.kt b/src/main/kotlin/entity/pokemon/TypePokemon.kt deleted file mode 100644 index f4ca27f..0000000 --- a/src/main/kotlin/entity/pokemon/TypePokemon.kt +++ /dev/null @@ -1,17 +0,0 @@ -package entity.pokemon - -import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource - -class TypePokemon( - - @JsonProperty("slot") - val slot: Number, - - @JsonProperty("pokemon") - val pokemon: NamedApiResource -) { - override fun toString(): String { - return "TypePokemon(slot=$slot, pokemon=$pokemon)" - } -} diff --git a/src/main/kotlin/exception/HttpBodyResponseException.kt b/src/main/kotlin/exception/HttpBodyResponseException.kt deleted file mode 100644 index 0cb549f..0000000 --- a/src/main/kotlin/exception/HttpBodyResponseException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package exception - -class HttpBodyResponseException(T: Any) : PokeApiException( - message = "Cannot parse response body for ${T::class.simpleName}" -) diff --git a/src/main/kotlin/exception/PokeApiException.kt b/src/main/kotlin/exception/PokeApiException.kt deleted file mode 100644 index ba0b412..0000000 --- a/src/main/kotlin/exception/PokeApiException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package exception - -import java.lang.Exception - -abstract class PokeApiException(message: String) : Exception(message) diff --git a/src/main/kotlin/exception/UnknownEndpointException.kt b/src/main/kotlin/exception/UnknownEndpointException.kt deleted file mode 100644 index 114a8a8..0000000 --- a/src/main/kotlin/exception/UnknownEndpointException.kt +++ /dev/null @@ -1,5 +0,0 @@ -package exception - -class UnknownEndpointException(className: String) : PokeApiException( - "Unknown endpoint: ${PokeApi.BASE_URL}/$className" -) diff --git a/src/main/kotlin/fr/tykok/pokeapi/PokeApi.kt b/src/main/kotlin/fr/tykok/pokeapi/PokeApi.kt new file mode 100644 index 0000000..2e48ad5 --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/PokeApi.kt @@ -0,0 +1,68 @@ +package fr.tykok.pokeapi + +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResources +import fr.tykok.pokeapi.http.getEndpoint +import okhttp3.OkHttpClient +import okhttp3.Request + +/** + * PokeApi main class, used to fetch resources from the PokeApi RESTful API. + * @author Tykok + * @version 2.0 + * @see PokeApi + * @see PokeApi Docs + */ +abstract class PokeApi { + companion object { + private const val VERSION = "v2" + const val BASE_URL = "https://pokeapi.co/api/$VERSION" + + /** + * Get a resource by its id. + */ + inline fun get(id: Int): T = + "$BASE_URL/${getEndpoint()}/$id" + .let { + Request.Builder().url(it).build() + }.let { + OkHttpClient().newCall(it).execute() + }.let { + Gson().fromJson(it.body?.string(), T::class.java) + } + + /** + * Get a resource by its name. + */ + inline fun get(name: String): T = + "$BASE_URL/${getEndpoint()}/$name" + .let { + Request.Builder().url(it).build() + }.let { + OkHttpClient().newCall(it).execute() + }.let { + Gson().fromJson(it.body?.string(), T::class.java) + } + + /** + * Get a list of resources. + */ + inline fun get( + limit: Int = 20, + offset: Int = 20 + ): NamedApiResources = + "$BASE_URL/${getEndpoint()}?offset=$offset&limit=$limit" + .let { + Request.Builder().url(it).build() + }.let { + OkHttpClient().newCall(it).execute() + }.let { + Gson().fromJson( + it.body?.string(), + object : TypeToken>() {}.type + ) + } + } +} diff --git a/src/main/kotlin/fr/tykok/pokeapi/entities/PokeApiObject.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/PokeApiObject.kt new file mode 100644 index 0000000..ad945eb --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/PokeApiObject.kt @@ -0,0 +1,3 @@ +package fr.tykok.pokeapi.entities + +interface PokeApiObject diff --git a/src/main/kotlin/entity/berries/Berry.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/Berry.kt similarity index 83% rename from src/main/kotlin/entity/berries/Berry.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/berries/Berry.kt index f81bad0..f7e12de 100644 --- a/src/main/kotlin/entity/berries/Berry.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/Berry.kt @@ -1,9 +1,10 @@ -package entity.berries +package fr.tykok.pokeapi.entities.berries import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.items.Item -import entity.pokemon.Type +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.items.Item +import fr.tykok.pokeapi.entities.pokemon.Type /** * Berries (Japanese: きのみ Tree Fruit) are small, juicy, fleshy fruit. @@ -13,58 +14,49 @@ import entity.pokemon.Type * @version 1.0.0 * @since 2022-07-27 */ -class Berry( - +data class Berry( /** * The identifier of the resource */ @JsonProperty("id") val id: Number, - /** * The name of the resource */ @JsonProperty("name") val name: String, - /** * Time it takes the tree to grow one stage, in hours. * Berry trees go through four of these growth stages before they can be picked. */ @JsonProperty("growth_time") val growthTime: Number, - /** * The maximum number of these berries that can grow on one tree in Generation IV. */ @JsonProperty("max_harvest") val maxHarvest: Number, - /** * The power of the move "Natural Gift" when used with this Berry. */ @JsonProperty("natural_gift_power") val naturalGiftPower: Number, - /** * The size of this Berry, in millimeters. */ @JsonProperty("size") val size: Number, - /** * The smoothness of this Berry, used in making Pokéblocks or Poffins. */ @JsonProperty("smoothness") val smoothness: Number, - /** * The speed at which this Berry dries out the soil as it grows. * A higher rate means the soil dries more quickly. */ @JsonProperty("soil_dryness") val soilDryness: Number, - /** * The firmness of this berry, used in making Pokéblocks or Poffins. * @see NamedApiResource @@ -72,14 +64,12 @@ class Berry( */ @JsonProperty("firmness") val firmness: NamedApiResource, - /** * A list of references to each flavor a berry can have and the potency of each of those flavors in regard to this berry. * @see BerryFlavorMap */ @JsonProperty("flavors") val flavors: Array, - /** * Berries are actually items. This is a reference to the item specific data for this berry. * @see NamedApiResource @@ -87,7 +77,6 @@ class Berry( */ @JsonProperty("item") val item: NamedApiResource, - /** * The type inherited by "Natural Gift" when used with this Berry. * @see NamedApiResource @@ -95,10 +84,4 @@ class Berry( */ @JsonProperty("natural_gift_type") val naturalGiftType: NamedApiResource -) { - override fun toString() = """ - Berry(id=$id, name='$name', growthTime=$growthTime, maxHarvest=$maxHarvest, naturalGiftPower=$naturalGiftPower, - size=$size, smoothness=$smoothness, soilDryness=$soilDryness, firmness=$firmness, - flavors=${flavors.contentToString()}, item=$item, naturalGiftType=$naturalGiftType) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/berries/BerryFirmness.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFirmness.kt similarity index 68% rename from src/main/kotlin/entity/berries/BerryFirmness.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFirmness.kt index 240d316..20a15c2 100644 --- a/src/main/kotlin/entity/berries/BerryFirmness.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFirmness.kt @@ -1,8 +1,9 @@ -package entity.berries +package fr.tykok.pokeapi.entities.berries import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @link https://pokeapi.co/docs/v2#berry-firmnesses @@ -10,14 +11,11 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-07-27 */ -class BerryFirmness( - +data class BerryFirmness( @JsonProperty("id") val id: Number, - @JsonProperty("name") val name: String, - /** * A list of the berries with this firmness. * @see NamedApiResource @@ -25,15 +23,10 @@ class BerryFirmness( */ @JsonProperty("berries") val berries: Array>, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array -) { - override fun toString() = """ - BerryFirmness(id=$id, name='$name', berries=${berries.contentToString()}, names=${names.contentToString()}) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/berries/BerryFlavor.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFlavor.kt similarity index 72% rename from src/main/kotlin/entity/berries/BerryFlavor.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFlavor.kt index 1968e59..3a07609 100644 --- a/src/main/kotlin/entity/berries/BerryFlavor.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFlavor.kt @@ -1,9 +1,10 @@ -package entity.berries +package fr.tykok.pokeapi.entities.berries import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource -import entity.contests.ContestType +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.contests.ContestType /** * @link https://pokeapi.co/docs/v2#berry-flavors @@ -11,27 +12,23 @@ import entity.contests.ContestType * @version 1.0.0 * @since 2022-07-27 */ -class BerryFlavor( - +data class BerryFlavor( /** * The identifier of the BerryFlavor */ @JsonProperty("id") val id: Number, - /** * The name of the BerryFlavor */ @JsonProperty("name") val name: String, - /** * A list of the berries with this flavor. * @see FlavorBerryMap */ @JsonProperty("berries") val berries: Array, - /** * The contest type that correlates with this berry flavor. * @see NamedApiResource @@ -39,16 +36,10 @@ class BerryFlavor( */ @JsonProperty("contest_type") val contestType: NamedApiResource, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array -) { - override fun toString() = """ - BerryFlavor(id=$id, name='$name', berries=${berries.contentToString()}, - contestType=$contestType, names=${names.contentToString()}) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/berries/BerryFlavorMap.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFlavorMap.kt similarity index 72% rename from src/main/kotlin/entity/berries/BerryFlavorMap.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFlavorMap.kt index 50a6d3a..e93acdc 100644 --- a/src/main/kotlin/entity/berries/BerryFlavorMap.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/BerryFlavorMap.kt @@ -1,7 +1,7 @@ -package entity.berries +package fr.tykok.pokeapi.entities.berries import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @link https://pokeapi.co/docs/v2#berries @@ -9,14 +9,12 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-07-27 */ -class BerryFlavorMap( - +data class BerryFlavorMap( /** * How powerful the referenced flavor is for this berry. */ @JsonProperty("potency") val potency: String, - /** * The referenced berry flavor. * With each reference you can have a ``BerryFlavor`` object. @@ -25,8 +23,4 @@ class BerryFlavorMap( */ @JsonProperty("flavor") val flavor: NamedApiResource -) { - override fun toString(): String { - return "BerryFlavorMap(potency=$potency, flavor=$flavor)" - } -} +) diff --git a/src/main/kotlin/entity/berries/FlavorBerryMap.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/FlavorBerryMap.kt similarity index 71% rename from src/main/kotlin/entity/berries/FlavorBerryMap.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/berries/FlavorBerryMap.kt index ba1888c..1407206 100644 --- a/src/main/kotlin/entity/berries/FlavorBerryMap.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/berries/FlavorBerryMap.kt @@ -1,7 +1,7 @@ -package entity.berries +package fr.tykok.pokeapi.entities.berries import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @link https://pokeapi.co/docs/v2#berry-flavors @@ -9,13 +9,12 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-07-27 */ -class FlavorBerryMap( +data class FlavorBerryMap( /** * How powerful the referenced flavor is for this berry. */ @JsonProperty("potency") val potency: Number, - /** * The berry with the referenced flavor. * @see NamedApiResource @@ -23,8 +22,4 @@ class FlavorBerryMap( */ @JsonProperty("berry") val berry: NamedApiResource -) { - override fun toString(): String { - return "FlavorBerryMap(potency=$potency, berry=$berry)" - } -} +) diff --git a/src/main/kotlin/entity/common/APIResource.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/APIResource.kt similarity index 82% rename from src/main/kotlin/entity/common/APIResource.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/APIResource.kt index 930e7cf..5f50e60 100644 --- a/src/main/kotlin/entity/common/APIResource.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/APIResource.kt @@ -1,4 +1,4 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty * @version 1.0.0 * @since 2022-08-27 */ -class APIResource( +data class APIResource( /** *The URL of the referenced resource. */ diff --git a/src/main/kotlin/entity/common/Description.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Description.kt similarity index 72% rename from src/main/kotlin/entity/common/Description.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/Description.kt index 263002a..1aec25e 100644 --- a/src/main/kotlin/entity/common/Description.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Description.kt @@ -1,7 +1,7 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.utility.Language +import fr.tykok.pokeapi.entities.utility.Language /** * @see Documentation of PokeApi @@ -10,14 +10,12 @@ import entity.utility.Language * @version 1.0.0 * @since 2022-08-27 */ -class Description( - +data class Description( /** * The localized description for an API resource in a specific language. */ @JsonProperty("description") val description: String, - /** * The language this name is in. * @see NamedApiResource @@ -25,8 +23,4 @@ class Description( */ @JsonProperty("language") val language: NamedApiResource -) { - override fun toString(): String { - return "Description(description='$description', language=$language)" - } -} +) diff --git a/src/main/kotlin/entity/common/Effect.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Effect.kt similarity index 72% rename from src/main/kotlin/entity/common/Effect.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/Effect.kt index 2b523b9..4efdb84 100644 --- a/src/main/kotlin/entity/common/Effect.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Effect.kt @@ -1,18 +1,17 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.utility.Language +import fr.tykok.pokeapi.entities.utility.Language /** * @see Documentation of PokeApi */ -class Effect( +data class Effect( /** * The localized effect text for an API resource in a specific language */ @JsonProperty("effect") val effect: String, - /** * The language this effect is in. * @see NamedApiResource @@ -20,8 +19,4 @@ class Effect( */ @JsonProperty("language") val language: NamedApiResource -) { - override fun toString(): String { - return "Effect(effect='$effect', language=$language)" - } -} +) diff --git a/src/main/kotlin/entity/common/Encounter.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Encounter.kt similarity index 77% rename from src/main/kotlin/entity/common/Encounter.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/Encounter.kt index 6ffc99c..40d8a54 100644 --- a/src/main/kotlin/entity/common/Encounter.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Encounter.kt @@ -1,8 +1,8 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.encounters.EncounterConditionValue -import entity.encounters.EncounterMethod +import fr.tykok.pokeapi.entities.encounters.EncounterConditionValue +import fr.tykok.pokeapi.entities.encounters.EncounterMethod /** * @see Documentation of PokeApi @@ -11,20 +11,17 @@ import entity.encounters.EncounterMethod * @version 1.0.0 * @since 2022-08-27 */ -class Encounter( - +data class Encounter( /** * The lowest level the Pokémon could be encountered at. */ @JsonProperty("min_level") val minLevel: Number, - /** * The highest level the Pokémon could be encountered at. */ @JsonProperty("max_level") val maxLevel: Number, - /** * A list of condition values that must be in effect for this encounter to occur. * @see EncounterConditionValue @@ -32,13 +29,11 @@ class Encounter( */ @JsonProperty("condition_values") val conditionValues: List>, - /** * Percent chance that this encounter will occur. */ @JsonProperty("chance") val chance: Number, - /** * The method by which this encounter happens. * @see EncounterMethod @@ -46,9 +41,4 @@ class Encounter( */ @JsonProperty("method") val method: NamedApiResource - -) { - override fun toString(): String = - "Encounter(minLevel=$minLevel, maxLevel=$maxLevel, conditionValues=$conditionValues, " + - "chance=$chance, method=$method)" -} +) diff --git a/src/main/kotlin/entity/common/FlavorText.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/FlavorText.kt similarity index 73% rename from src/main/kotlin/entity/common/FlavorText.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/FlavorText.kt index e09cd54..ba96160 100644 --- a/src/main/kotlin/entity/common/FlavorText.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/FlavorText.kt @@ -1,20 +1,18 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.games.Version -import entity.utility.Language +import fr.tykok.pokeapi.entities.games.Version +import fr.tykok.pokeapi.entities.utility.Language /** * @see Documentation of PokeApi */ -class FlavorText( - +data class FlavorText( /** * The localized flavor text for an API resource in a specific language */ @JsonProperty("flavor_text") val flavorText: String, - /** * The language this name is in. * @see NamedApiResource @@ -22,7 +20,6 @@ class FlavorText( */ @JsonProperty("language") val language: NamedApiResource, - /** * The game version this flavor text is extracted from. * @see NamedApiResource @@ -30,8 +27,4 @@ class FlavorText( */ @JsonProperty("version") val version: NamedApiResource? -) { - override fun toString(): String { - return "FlavorText(flavorText='$flavorText', language=$language, version=$version)" - } -} +) diff --git a/src/main/kotlin/entity/common/GenerationGameIndex.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/GenerationGameIndex.kt similarity index 81% rename from src/main/kotlin/entity/common/GenerationGameIndex.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/GenerationGameIndex.kt index 49609cb..2418c52 100644 --- a/src/main/kotlin/entity/common/GenerationGameIndex.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/GenerationGameIndex.kt @@ -1,7 +1,7 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.games.Generation +import fr.tykok.pokeapi.entities.games.Generation /** * @see Documentation of PokeApi @@ -10,14 +10,12 @@ import entity.games.Generation * @version 1.0.0 * @since 2022-08-27 */ -class GenerationGameIndex( - +data class GenerationGameIndex( /** * The internal id of an API resource within game data. */ @JsonProperty("game_index") val gameIndex: Number, - /** * The generation relevent to this game index. * @see NamedApiResource diff --git a/src/main/kotlin/entity/common/MachineVersionDetail.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/MachineVersionDetail.kt similarity index 70% rename from src/main/kotlin/entity/common/MachineVersionDetail.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/MachineVersionDetail.kt index ef7be0b..9abe5c1 100644 --- a/src/main/kotlin/entity/common/MachineVersionDetail.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/MachineVersionDetail.kt @@ -1,8 +1,8 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.games.VersionGroup -import entity.machines.Machine +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.machines.Machine /** * @see Documentation of PokeApi @@ -11,7 +11,7 @@ import entity.machines.Machine * @version 1.0.0 * @since 2022-08-27 */ -class MachineVersionDetail( +data class MachineVersionDetail( /** * The machine that teaches a move from an item. * @see NamedApiResource @@ -19,7 +19,6 @@ class MachineVersionDetail( */ @JsonProperty("machine") val machine: APIResource, - /** * The version group of this specific machine. * @see NamedApiResource @@ -27,8 +26,4 @@ class MachineVersionDetail( */ @JsonProperty("version_group") val versionGroup: NamedApiResource -) { - override fun toString(): String { - return "MachineVersionDetail(machine=$machine, versionGroup=$versionGroup)" - } -} +) diff --git a/src/main/kotlin/entity/common/Name.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Name.kt similarity index 73% rename from src/main/kotlin/entity/common/Name.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/Name.kt index a9a4c94..858262a 100644 --- a/src/main/kotlin/entity/common/Name.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/Name.kt @@ -1,7 +1,7 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.utility.Language +import fr.tykok.pokeapi.entities.utility.Language /** * @link https://pokeapi.co/docs/v2#common-models @@ -9,14 +9,12 @@ import entity.utility.Language * @version 1.0.0 * @since 2022-07-27 */ -class Name( - +data class Name( /** * The localized name for an API resource in a specific language */ @JsonProperty("name") val name: String, - /** * The language this name is in. * @see NamedApiResource @@ -24,8 +22,4 @@ class Name( */ @JsonProperty("language") val language: NamedApiResource -) { - override fun toString(): String { - return "Name(name='$name', language=$language)" - } -} +) diff --git a/src/main/kotlin/entity/common/NamedApiResource.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/NamedApiResource.kt similarity index 60% rename from src/main/kotlin/entity/common/NamedApiResource.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/NamedApiResource.kt index 851815f..97d6dc3 100644 --- a/src/main/kotlin/entity/common/NamedApiResource.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/NamedApiResource.kt @@ -1,7 +1,9 @@ -package entity.common +package fr.tykok.pokeapi.entities.common -import PokeApi import com.fasterxml.jackson.annotation.JsonProperty +import com.google.gson.Gson +import okhttp3.OkHttpClient +import okhttp3.Request /** * NamedApiResource contains the name and the url to get the object from the API resource (pokeapi.co). @@ -10,30 +12,31 @@ import com.fasterxml.jackson.annotation.JsonProperty * @version 1.0.0 * @since 2022-07-27 */ -class NamedApiResource( - +data class NamedApiResource( /** * The name of the referenced resource. */ @JsonProperty("name") val name: String, - /** * The URL of the referenced resource. */ @JsonProperty("url") val url: String? = null, - val resource: T? = null -) { - override fun toString(): String { - return "NamedApiResource(name='$name', url=$url)" - } -} +) inline fun NamedApiResource.get(): T? = if (this.url != null) { - PokeApi.fetch(fullUrl = this.url) + Request + .Builder() + .url(this.url) + .build() + .let { + OkHttpClient().newCall(it).execute() + }.let { + Gson().fromJson(it.body?.string(), T::class.java) + } } else { null } diff --git a/src/main/kotlin/entity/common/NamedApiResources.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/NamedApiResources.kt similarity index 60% rename from src/main/kotlin/entity/common/NamedApiResources.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/NamedApiResources.kt index bce23f8..6c35714 100644 --- a/src/main/kotlin/entity/common/NamedApiResources.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/NamedApiResources.kt @@ -1,23 +1,16 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -class NamedApiResources( +data class NamedApiResources( @JsonProperty("count") val count: Int, - @JsonProperty("next") val next: String?, - @JsonProperty("previous") val previous: String?, - @JsonProperty("results") val results: List> -) { - override fun toString() = - "NamedApiResources(count=$count, next=$next, previous=$previous, result=$results)" -} +) -inline fun NamedApiResources.get(): List = - this.results.map { it.get()!! } +inline fun NamedApiResources.get(): List = this.results.map { it.get()!! } diff --git a/src/main/kotlin/entity/common/VerboseEffect.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VerboseEffect.kt similarity index 84% rename from src/main/kotlin/entity/common/VerboseEffect.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/VerboseEffect.kt index 786dd1d..f42af6e 100644 --- a/src/main/kotlin/entity/common/VerboseEffect.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VerboseEffect.kt @@ -1,7 +1,7 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.utility.Language +import fr.tykok.pokeapi.entities.utility.Language /** * @see Documentation of PokeApi @@ -10,20 +10,17 @@ import entity.utility.Language * @version 1.0.0 * @since 2022-08-27 */ -class VerboseEffect( - +data class VerboseEffect( /** * The localized effect text for an API resource in a specific language. */ @JsonProperty("effect") val effect: String, - /** * The localized effect text in brief. */ @JsonProperty("short_effect") val shortEffect: String, - /** * The language this effect is in. * @see NamedApiResource diff --git a/src/main/kotlin/entity/common/VersionEncounterDetail.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionEncounterDetail.kt similarity index 74% rename from src/main/kotlin/entity/common/VersionEncounterDetail.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionEncounterDetail.kt index 18497ea..123b1e3 100644 --- a/src/main/kotlin/entity/common/VersionEncounterDetail.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionEncounterDetail.kt @@ -1,7 +1,7 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.games.Version +import fr.tykok.pokeapi.entities.games.Version /** * @see Documentation of PokeApi @@ -10,8 +10,7 @@ import entity.games.Version * @version 1.0.0 * @since 2022-08-27 */ -class VersionEncounterDetail( - +data class VersionEncounterDetail( /** * The game version this encounter happens in. * @see NamedApiResource @@ -19,20 +18,14 @@ class VersionEncounterDetail( */ @JsonProperty("version") val version: NamedApiResource, - /** * The total percentage of all encounter potential. */ @JsonProperty("max_chance") val maxChance: Number, - /** * A list of encounters and their specifics. */ @JsonProperty("encounter_details") val encounterDetails: List - -) { - override fun toString() = - "VersionEncounterDetail(version=$version, maxChance=$maxChance, encounterDetails=$encounterDetails)" -} +) diff --git a/src/main/kotlin/entity/common/VersionGameIndex.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionGameIndex.kt similarity index 71% rename from src/main/kotlin/entity/common/VersionGameIndex.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionGameIndex.kt index 2378f91..c1e0087 100644 --- a/src/main/kotlin/entity/common/VersionGameIndex.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionGameIndex.kt @@ -1,12 +1,11 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.games.Version +import fr.tykok.pokeapi.entities.games.Version -class VersionGameIndex( +data class VersionGameIndex( @JsonProperty("game_index") val gameIndex: Int, - /** * The version relevent to this game index. * @see NamedApiResource diff --git a/src/main/kotlin/entity/common/VersionGroupFlavorText.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionGroupFlavorText.kt similarity index 80% rename from src/main/kotlin/entity/common/VersionGroupFlavorText.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionGroupFlavorText.kt index e1da6a3..3e397c3 100644 --- a/src/main/kotlin/entity/common/VersionGroupFlavorText.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/common/VersionGroupFlavorText.kt @@ -1,8 +1,8 @@ -package entity.common +package fr.tykok.pokeapi.entities.common import com.fasterxml.jackson.annotation.JsonProperty -import entity.games.VersionGroup -import entity.utility.Language +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.utility.Language /** * @see Documentation of PokeApi @@ -11,14 +11,12 @@ import entity.utility.Language * @version 1.0.0 * @since 2022-08-27 */ -class VersionGroupFlavorText( - +data class VersionGroupFlavorText( /** * The localized name for an API resource in a specific language. */ @JsonProperty("text") val text: String, - /** * The language this name is in. * @see NamedApiResource @@ -26,7 +24,6 @@ class VersionGroupFlavorText( */ @JsonProperty("language") val language: NamedApiResource, - /** * The version group which uses this flavor text. * @see NamedApiResource diff --git a/src/main/kotlin/entity/contests/ContestEffect.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestEffect.kt similarity index 79% rename from src/main/kotlin/entity/contests/ContestEffect.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestEffect.kt index c253102..27533ee 100644 --- a/src/main/kotlin/entity/contests/ContestEffect.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestEffect.kt @@ -1,8 +1,9 @@ -package entity.contests +package fr.tykok.pokeapi.entities.contests import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Effect -import entity.common.FlavorText +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Effect +import fr.tykok.pokeapi.entities.common.FlavorText /** * `ContestEffects` class refers to the effects of move on the public when used in contests. @@ -15,41 +16,32 @@ import entity.common.FlavorText * @version 1.0.0 * @since 2022-08-27 */ -class ContestEffect( - +data class ContestEffect( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The base number of hearts the user of this move gets. */ @JsonProperty("appeal") val appeal: Number, - /** * The base number of hearts the user's opponent loses. */ @JsonProperty("jam") val jam: Number, - /** * The result of this contest effect listed in different languages. * @see Effect */ @JsonProperty("effect_entries") val effectEntries: Array, - /** * The flavor text of this contest effect listed in different languages. * @see FlavorText */ @JsonProperty("flavor_text_entries") val flavorTextEntries: Array -) { - override fun toString(): String { - return "ContestEffect(id=$id, appeal=$appeal, jam=$jam, effectEntries=${effectEntries.contentToString()}, flavorTextEntries=${flavorTextEntries.contentToString()})" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/contests/ContestName.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestName.kt similarity index 78% rename from src/main/kotlin/entity/contests/ContestName.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestName.kt index 1e3ee83..bc39c3c 100644 --- a/src/main/kotlin/entity/contests/ContestName.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestName.kt @@ -1,8 +1,8 @@ -package entity.contests +package fr.tykok.pokeapi.entities.contests import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.utility.Language +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.utility.Language /** * ContestName classe used to refer to a specific categories according to the color of the berry. @@ -16,20 +16,17 @@ import entity.utility.Language * @version 1.0.0 * @since 2022-08-27 */ -class ContestName( - +data class ContestName( /** * The name for this contest. */ @JsonProperty("name") val name: String, - /** * The color associated with this contest's name. */ @JsonProperty("color") val color: String, - /** * The language that this name is in. * @see NamedApiResource @@ -37,8 +34,4 @@ class ContestName( */ @JsonProperty("language") val language: NamedApiResource -) { - override fun toString(): String { - return "ContestName(name='$name', color='$color', language=$language)" - } -} +) diff --git a/src/main/kotlin/entity/contests/ContestType.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestType.kt similarity index 83% rename from src/main/kotlin/entity/contests/ContestType.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestType.kt index 2473f22..e42b124 100644 --- a/src/main/kotlin/entity/contests/ContestType.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/ContestType.kt @@ -1,8 +1,9 @@ -package entity.contests +package fr.tykok.pokeapi.entities.contests import com.fasterxml.jackson.annotation.JsonProperty -import entity.berries.BerryFlavor -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.berries.BerryFlavor +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * The types given to Pokémon in the contest are categories that judges use to evaluate the condition of a Pokémon in Pokémon contests. @@ -25,20 +26,17 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class ContestType( - +data class ContestType( /** * Identifier of the resource */ @JsonProperty("id") val id: Number, - /** * Name of the resource */ @JsonProperty("name") val name: String, - /** * The berry flavor that correlates with this contest type. * @see NamedApiResource @@ -46,14 +44,10 @@ class ContestType( */ @JsonProperty("berry_flavor") val berryFlavor: NamedApiResource, - /** * The name of this contest type listed in different languages. * @see ContestName */ @JsonProperty("names") val names: Array -) { - override fun toString() = - "ContestType(id=$id, name='$name', berryFlavor=$berryFlavor, names=${names.contentToString()})" -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/contests/SuperContestEffects.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/SuperContestEffects.kt similarity index 78% rename from src/main/kotlin/entity/contests/SuperContestEffects.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/contests/SuperContestEffects.kt index f231fb0..b2f61df 100644 --- a/src/main/kotlin/entity/contests/SuperContestEffects.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/contests/SuperContestEffects.kt @@ -1,9 +1,10 @@ -package entity.contests +package fr.tykok.pokeapi.entities.contests import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.FlavorText -import entity.common.NamedApiResource -import entity.moves.Move +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.FlavorText +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.moves.Move /** * `SuperContestEffects` class refers to the effects of move on the public when used in super contests. @@ -17,27 +18,23 @@ import entity.moves.Move * @version 1.0.0 * @since 2022-08-27 */ -class SuperContestEffects( - +data class SuperContestEffects( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The level of appeal this super contest effect has. */ @JsonProperty("appeal") val appeal: Number, - /** * The flavor text of this super contest effect listed in different languages. * @see FlavorText */ @JsonProperty("flavor_text_entries") val flavorTextEntries: Array, - /** * A list of moves that have the effect when used in super contests. * @see NamedApiResource @@ -45,8 +42,4 @@ class SuperContestEffects( */ @JsonProperty("moves") val moves: List> -) { - override fun toString(): String = """ - SuperContestEffects(id=$id, appeal=$appeal, flavorTextEntries=${flavorTextEntries.contentToString()}, moves=$moves) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/encounters/EncounterCondition.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterCondition.kt similarity index 77% rename from src/main/kotlin/entity/encounters/EncounterCondition.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterCondition.kt index 4c8b291..b0a2600 100644 --- a/src/main/kotlin/entity/encounters/EncounterCondition.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterCondition.kt @@ -1,8 +1,9 @@ -package entity.encounters +package fr.tykok.pokeapi.entities.encounters import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Conditions which affect what Pokemon might appear in the wild. @@ -15,27 +16,23 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class EncounterCondition( - +data class EncounterCondition( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array, - /** * A list of possible values for this encounter condition. * @see NamedApiResource @@ -43,8 +40,4 @@ class EncounterCondition( */ @JsonProperty("values") val values: Array> -) { - override fun toString() = - "EncounterCondition(id=$id, name='$name', names=${names.contentToString()}, " + - "values=${values.contentToString()})" -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/encounters/EncounterConditionValue.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterConditionValue.kt similarity index 79% rename from src/main/kotlin/entity/encounters/EncounterConditionValue.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterConditionValue.kt index 64efc72..609a093 100644 --- a/src/main/kotlin/entity/encounters/EncounterConditionValue.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterConditionValue.kt @@ -1,8 +1,9 @@ -package entity.encounters +package fr.tykok.pokeapi.entities.encounters import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Encounter condition values are the various states that an encounter condition can have, i.e., time of day can be either day or night. @@ -14,19 +15,17 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class EncounterConditionValue( +data class EncounterConditionValue( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The condition this encounter condition value pertains to. * @see NamedApiResource @@ -34,14 +33,10 @@ class EncounterConditionValue( */ @JsonProperty("condition") val condition: NamedApiResource, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array -) { - override fun toString() = - "EncounterConditionValue(id=$id, name='$name', condition=$condition, names=${names.contentToString()})" -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/encounters/EncounterMethod.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterMethod.kt similarity index 80% rename from src/main/kotlin/entity/encounters/EncounterMethod.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterMethod.kt index 19cedc0..29374a6 100644 --- a/src/main/kotlin/entity/encounters/EncounterMethod.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/encounters/EncounterMethod.kt @@ -1,7 +1,8 @@ -package entity.encounters +package fr.tykok.pokeapi.entities.encounters import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name /** * EncounterMethod define how you can encounter a Pokemon. @@ -16,34 +17,26 @@ import entity.common.Name * @version 1.0.0 * @since 2022-08-27 */ -class EncounterMethod( - +data class EncounterMethod( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * A good value for sorting. */ @JsonProperty("order") val order: Number, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array -) { - override fun toString(): String { - return "EncounterMethod(id=$id, name='$name', order=$order, names=${names.contentToString()})" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/evolution/ChainLink.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/ChainLink.kt similarity index 79% rename from src/main/kotlin/entity/evolution/ChainLink.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/evolution/ChainLink.kt index ef24801..9bf963e 100644 --- a/src/main/kotlin/entity/evolution/ChainLink.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/ChainLink.kt @@ -1,8 +1,8 @@ -package entity.evolution +package fr.tykok.pokeapi.entities.evolution import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies /** * ChainLink, used to link a Pokemon with this evolution. With this classe you can have @@ -17,14 +17,12 @@ import entity.pokemon.PokemonSpecies * @version 1.0.0 * @since 2022-08-27 */ -class ChainLink( - +data class ChainLink( /** * Whether or not this link is for a baby Pokémon. This would only ever be true on the base link. */ @JsonProperty("is_baby") val isBaby: Boolean, - /** * The Pokémon species at this point in the evolution chain. * @see NamedApiResource @@ -32,22 +30,16 @@ class ChainLink( */ @JsonProperty("species") val species: NamedApiResource, - /** * All details regarding the specific details of the referenced Pokémon species evolution. * @see EvolutionDetail */ @JsonProperty("evolution_details") val evolutionDetails: Array, - /** * A List of chain objects. * @see ChainLink */ @JsonProperty("evolves_to") val evolvesTo: Array -) { - override fun toString(): String { - return "ChainLink(isBaby=$isBaby, species=$species, evolutionDetails=${evolutionDetails.contentToString()}, evolvesTo=${evolvesTo.contentToString()})" - } -} +) diff --git a/src/main/kotlin/entity/evolution/EvolutionChain.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionChain.kt similarity index 82% rename from src/main/kotlin/entity/evolution/EvolutionChain.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionChain.kt index d579c5a..f6a65c0 100644 --- a/src/main/kotlin/entity/evolution/EvolutionChain.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionChain.kt @@ -1,8 +1,9 @@ -package entity.evolution +package fr.tykok.pokeapi.entities.evolution import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.items.Item +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.items.Item /** * Evolution chains are essentially family trees. @@ -15,14 +16,12 @@ import entity.items.Item * @version 1.0.0 * @since 2022-08-27 */ -class EvolutionChain( - +data class EvolutionChain( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The item that a Pokémon would be holding when mating that would trigger the egg hatching a baby Pokémon rather than a basic Pokémon. * @see NamedApiResource @@ -30,7 +29,6 @@ class EvolutionChain( */ @JsonProperty("baby_trigger_item") val babyTriggerItem: NamedApiResource?, - /** * The base chain link object. Each link contains evolution details for a Pokémon in the chain. * Each link references the next Pokémon in the natural evolution order. @@ -39,9 +37,4 @@ class EvolutionChain( */ @JsonProperty("chain") val chain: ChainLink - -) { - override fun toString(): String { - return "EvolutionChain(id=$id, babyTriggerItem=$babyTriggerItem, chain=$chain)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/evolution/EvolutionDetail.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionDetail.kt similarity index 92% rename from src/main/kotlin/entity/evolution/EvolutionDetail.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionDetail.kt index 87e6c77..ef2856a 100644 --- a/src/main/kotlin/entity/evolution/EvolutionDetail.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionDetail.kt @@ -1,12 +1,12 @@ -package entity.evolution +package fr.tykok.pokeapi.entities.evolution import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.items.Item -import entity.locations.Location -import entity.moves.Move -import entity.pokemon.PokemonSpecies -import entity.pokemon.Type +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.items.Item +import fr.tykok.pokeapi.entities.locations.Location +import fr.tykok.pokeapi.entities.moves.Move +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.pokemon.Type /** * EvolutionDetail define all possibility to make possible the evolution of the Pokemon. @@ -18,8 +18,7 @@ import entity.pokemon.Type * @version 1.0.0 * @since 2022-08-27 */ -class EvolutionDetail( - +data class EvolutionDetail( /** * The item required to cause evolution this into Pokémon species. * @see NamedApiResource @@ -27,7 +26,6 @@ class EvolutionDetail( */ @JsonProperty("item") val item: NamedApiResource?, - /** * The type of event that triggers evolution into this Pokémon species. * @see NamedApiResource @@ -35,13 +33,11 @@ class EvolutionDetail( */ @JsonProperty("trigger") val trigger: NamedApiResource?, - /** * The id of the gender of the evolving Pokémon species must be in order to evolve into this Pokémon species. */ @JsonProperty("number") val gender: Number?, - /** * The item the evolving Pokémon species must be holding during the evolution trigger event to evolve into this Pokémon species. * @see NamedApiResource @@ -49,7 +45,6 @@ class EvolutionDetail( */ @JsonProperty("held_item") val heldItem: NamedApiResource?, - /** * The move that must be known by the evolving Pokémon species during the evolution trigger event in order to evolve into this Pokémon species. * @see NamedApiResource @@ -57,7 +52,6 @@ class EvolutionDetail( */ @JsonProperty("known_move") val knownMove: NamedApiResource?, - /** * The evolving Pokémon species must know a move with this type during the evolution trigger event in order to evolve into this Pokémon species. * @see NamedApiResource @@ -65,7 +59,6 @@ class EvolutionDetail( */ @JsonProperty("known_move_type") val knownMoveType: NamedApiResource?, - /** * The location the evolution must be triggered at. * @see NamedApiResource @@ -73,37 +66,31 @@ class EvolutionDetail( */ @JsonProperty("location") val location: NamedApiResource?, - /** * The minimum required level of the evolving Pokémon species to evolve into this Pokémon species. */ @JsonProperty("min_level") val minLevel: Number, - /** * The minimum required level of happiness the evolving Pokémon species to evolve into this Pokémon species. */ @JsonProperty("min_happiness") val minHappiness: Number?, - /** * The minimum required level of beauty the evolving Pokémon species to evolve into this Pokémon species. */ @JsonProperty("min_beauty") val minBeauty: Number?, - /** * The minimum required level of affection the evolving Pokémon species to evolve into this Pokémon species. */ @JsonProperty("min_affection") val minAffection: Number?, - /** * Whether or not it must be raining in the overworld to cause evolution this Pokémon species. */ @JsonProperty("needs_overworld_rain") val needsOverworldRain: Boolean, - /** * The Pokémon species that must be in the players party in order for the evolving Pokémon species to evolve into this Pokémon species. * @see NamedApiResource @@ -111,7 +98,6 @@ class EvolutionDetail( */ @JsonProperty("party_species") val partySpecies: Number?, - /** * The player must have a Pokémon of this type in their party during the evolution trigger event in order for * the evolving Pokémon species to evolve into this Pokémon species. @@ -120,19 +106,16 @@ class EvolutionDetail( */ @JsonProperty("party_type") val partyType: NamedApiResource?, - /** * The required relation between the Pokémon's Attack and Defense stats. 1 means Attack > Defense. 0 means Attack = Defense. -1 means Attack < Defense. */ @JsonProperty("relative_physical_stats") val relativePhysicalStats: Number?, - /** * The required time of day. Day or night. */ @JsonProperty("time_of_day") val timeOfDay: String, - /** * Pokémon species for which this one must be traded. * @see NamedApiResource @@ -140,7 +123,6 @@ class EvolutionDetail( */ @JsonProperty("trade_species") val tradeSpecies: NamedApiResource?, - /** * Whether or not the 3DS needs to be turned upside-down as this Pokémon levels up. */ diff --git a/src/main/kotlin/entity/evolution/EvolutionTrigger.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionTrigger.kt similarity index 75% rename from src/main/kotlin/entity/evolution/EvolutionTrigger.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionTrigger.kt index 2868d6a..55c59ab 100644 --- a/src/main/kotlin/entity/evolution/EvolutionTrigger.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/evolution/EvolutionTrigger.kt @@ -1,9 +1,10 @@ -package entity.evolution +package fr.tykok.pokeapi.entities.evolution import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource -import entity.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies /** * Evolution triggers are the events and conditions that cause a Pokémon to evolve. @@ -15,20 +16,17 @@ import entity.pokemon.PokemonSpecies * @version 1.0.0 * @since 2022-08-27 */ -class EvolutionTrigger( - +data class EvolutionTrigger( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see NamedApiResource @@ -36,7 +34,6 @@ class EvolutionTrigger( */ @JsonProperty("names") val names: Array, - /** * A list of pokemon species that result from this evolution trigger. * @see NamedApiResource @@ -44,8 +41,4 @@ class EvolutionTrigger( */ @JsonProperty("pokemon_species") val pokemonSpecies: Array> -) { - override fun toString(): String { - return "EvolutionTrigger(id=$id, name='$name', names=${names.contentToString()}, pokemonSpecies=${pokemonSpecies.contentToString()})" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/games/Generation.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/games/Generation.kt similarity index 75% rename from src/main/kotlin/entity/games/Generation.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/games/Generation.kt index 6e44f8d..e17ea17 100644 --- a/src/main/kotlin/entity/games/Generation.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/games/Generation.kt @@ -1,13 +1,14 @@ -package entity.games +package fr.tykok.pokeapi.entities.games import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource -import entity.locations.Region -import entity.moves.Move -import entity.pokemon.Ability -import entity.pokemon.PokemonSpecies -import entity.pokemon.Type +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.locations.Region +import fr.tykok.pokeapi.entities.moves.Move +import fr.tykok.pokeapi.entities.pokemon.Ability +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.pokemon.Type /** * A generation is a grouping of the Pokémon games that separates them based on the Pokémon they include. @@ -21,61 +22,47 @@ import entity.pokemon.Type * @version 1.0.0 * @since 2022-08-27 */ -class Generation( - +data class Generation( @JsonProperty("id") val id: Number, - @JsonProperty("name") val name: String, - /** * @see NamedApiResource * @see Ability */ @JsonProperty("abilities") val abilities: List>, - @JsonProperty("names") val names: List, - /** * @see NamedApiResource * @see Region */ @JsonProperty("main_region") val mainRegion: NamedApiResource, - /** * @see NamedApiResource * @see Move */ @JsonProperty("moves") val moves: List>, - /** * @see NamedApiResource * @see PokemonSpecies */ @JsonProperty("pokemon_species") val pokemonSpecies: List>, - /** * @see NamedApiResource * @see Type */ @JsonProperty("types") val types: List>, - /** * @see NamedApiResource * @see VersionGroup */ @JsonProperty("version_groups") val versionGroups: List> -) { - override fun toString(): String { - return "Generation(id=$id, name='$name', abilities=$abilities, names=$names, mainRegion=$mainRegion, moves=$moves, " + - "pokemonSpecies=$pokemonSpecies, types=$types, versionGroups=$versionGroups)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/games/Pokedex.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/games/Pokedex.kt similarity index 81% rename from src/main/kotlin/entity/games/Pokedex.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/games/Pokedex.kt index aa272df..44fa6da 100644 --- a/src/main/kotlin/entity/games/Pokedex.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/games/Pokedex.kt @@ -1,10 +1,11 @@ -package entity.games +package fr.tykok.pokeapi.entities.games import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.Name -import entity.common.NamedApiResource -import entity.locations.Region +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.locations.Region /** * A Pokédex is a handheld electronic encyclopedia device; one which is capable of recording and retaining information @@ -18,47 +19,40 @@ import entity.locations.Region * @version 1.0.0 * @since 2022-08-27 */ -class Pokedex( - +data class Pokedex( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * Whether or not this Pokédex originated in the main series of the video games. */ @JsonProperty("is_main_series") val isMainSeries: Boolean, - /** * The description of this resource listed in different languages. * @see Description */ @JsonProperty("descriptions") val descriptions: List, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of Pokémon catalogued in this Pokédex and their indexes. * @see PokemonEntry */ @JsonProperty("pokemon_entries") val pokemonEntries: List, - /** * The region this Pokédex catalogues Pokémon for. * @see NamedApiResource @@ -66,7 +60,6 @@ class Pokedex( */ @JsonProperty("region") val region: NamedApiResource?, - /** * A list of version groups this Pokédex is relevant to. * @see NamedApiResource @@ -74,8 +67,4 @@ class Pokedex( */ @JsonProperty("version_groups") val versionGroups: List>? -) { - override fun toString(): String { - return "Pokedex(id=$id, name='$name', isMainSeries=$isMainSeries, descriptions=$descriptions, names=$names, pokemonEntries=$pokemonEntries, region=$region, versionGroups=$versionGroups)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/games/PokemonEntry.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/games/PokemonEntry.kt similarity index 68% rename from src/main/kotlin/entity/games/PokemonEntry.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/games/PokemonEntry.kt index 5315e48..df7821c 100644 --- a/src/main/kotlin/entity/games/PokemonEntry.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/games/PokemonEntry.kt @@ -1,8 +1,8 @@ -package entity.games +package fr.tykok.pokeapi.entities.games import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies /** * @see Documentation of PokeApi @@ -11,14 +11,12 @@ import entity.pokemon.PokemonSpecies * @version 1.0.0 * @since 2022-08-27 */ -class PokemonEntry( - +data class PokemonEntry( /** * The index of this Pokémon species entry within the Pokédex. */ @JsonProperty("entry_number") val entryNumber: Number, - /** * The Pokémon species being encountered. * @see NamedApiResource @@ -26,8 +24,4 @@ class PokemonEntry( */ @JsonProperty("pokemon_species") val pokemonSpecies: NamedApiResource -) { - override fun toString(): String { - return "PokemonEntry(entryNumber=$entryNumber, pokemonSpecies=$pokemonSpecies)" - } -} +) diff --git a/src/main/kotlin/entity/games/Version.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/games/Version.kt similarity index 78% rename from src/main/kotlin/entity/games/Version.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/games/Version.kt index 8558c44..a20a3fd 100644 --- a/src/main/kotlin/entity/games/Version.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/games/Version.kt @@ -1,8 +1,9 @@ -package entity.games +package fr.tykok.pokeapi.entities.games import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Versions of the games, e.g., Red, Blue or Yellow. @@ -14,26 +15,23 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class Version( +data class Version( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array, - /** * A list of version groups this Pokédex is relevant to. * @see NamedApiResource @@ -41,8 +39,4 @@ class Version( */ @JsonProperty("version_group") val versionGroup: NamedApiResource? = null -) { - override fun toString(): String { - return "Version(id=$id, name='$name', names=${names.contentToString()}, versionGroups=$versionGroup)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/games/VersionGroup.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/games/VersionGroup.kt similarity index 82% rename from src/main/kotlin/entity/games/VersionGroup.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/games/VersionGroup.kt index 9ab15db..566cc62 100644 --- a/src/main/kotlin/entity/games/VersionGroup.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/games/VersionGroup.kt @@ -1,9 +1,10 @@ -package entity.games +package fr.tykok.pokeapi.entities.games import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.locations.Region -import entity.moves.MoveLearnMethod +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.locations.Region +import fr.tykok.pokeapi.entities.moves.MoveLearnMethod /** * Version groups categorize highly similar versions of the games. @@ -15,26 +16,22 @@ import entity.moves.MoveLearnMethod * @version 1.0.0 * @since 2022-08-27 */ -class VersionGroup( - +data class VersionGroup( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * Order for sorting. Almost by date of release, except similar versions are grouped together. */ @JsonProperty("order") val order: Number, - /** * The generation this version was introduced in. * @see NamedApiResource @@ -42,7 +39,6 @@ class VersionGroup( */ @JsonProperty("generation") val generation: NamedApiResource, - /** * A list of methods in which Pokémon can learn moves in this version group. * @see NamedApiResource @@ -50,7 +46,6 @@ class VersionGroup( */ @JsonProperty("move_learn_methods") val moveLearnMethods: List>, - /** * A list of Pokédexes introduces in this version group. * @see NamedApiResource @@ -58,7 +53,6 @@ class VersionGroup( */ @JsonProperty("pokedexes") val pokedexes: List>, - /** * A list of regions that can be visited in this version group. * @see NamedApiResource @@ -66,7 +60,6 @@ class VersionGroup( */ @JsonProperty("regions") val regions: List>, - /** * The versions this version group owns. * @see NamedApiResource @@ -74,8 +67,4 @@ class VersionGroup( */ @JsonProperty("versions") val versions: List> -) { - override fun toString(): String { - return "VersionGroup(id=$id, name='$name', order=$order, generation=$generation, moveLearnMethods=$moveLearnMethods, pokedexes=$pokedexes, regions=$regions, versions=$versions)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/items/Item.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/Item.kt similarity index 79% rename from src/main/kotlin/entity/items/Item.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/Item.kt index f38d85f..c37aec4 100644 --- a/src/main/kotlin/entity/items/Item.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/Item.kt @@ -1,14 +1,15 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.APIResource -import entity.common.GenerationGameIndex -import entity.common.MachineVersionDetail -import entity.common.Name -import entity.common.NamedApiResource -import entity.common.VerboseEffect -import entity.common.VersionGroupFlavorText -import entity.evolution.EvolutionChain +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.APIResource +import fr.tykok.pokeapi.entities.common.GenerationGameIndex +import fr.tykok.pokeapi.entities.common.MachineVersionDetail +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VerboseEffect +import fr.tykok.pokeapi.entities.common.VersionGroupFlavorText +import fr.tykok.pokeapi.entities.evolution.EvolutionChain /** * An item is an object in the games which the player can pick up, keep in their bag, and use in some manner. @@ -21,32 +22,27 @@ import entity.evolution.EvolutionChain * @version 1.0.0 * @since 2022-08-27 */ -class Item( - +data class Item( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The price of this item in stores. */ @JsonProperty("cost") val cost: Int, - /** * The power of the move Fling when used with this item. */ @JsonProperty("fling_power") val flingPower: Number?, - /** * The effect of the move Fling when used with this item. * @see NamedApiResource @@ -54,7 +50,6 @@ class Item( */ @JsonProperty("fling_effect") val flingEffect: NamedApiResource?, - /** * A list of attributes this item has. * @see NamedApiResource @@ -62,7 +57,6 @@ class Item( */ @JsonProperty("attributes") val attributes: List>, - /** * The category of items this item falls into. * @see NamedApiResource @@ -70,49 +64,42 @@ class Item( */ @JsonProperty("category") val category: NamedApiResource, - /** * The effect of this ability listed in different languages. * @see VerboseEffect */ @JsonProperty("effect_entries") val effectEntries: List, - /** * The flavor text of this ability listed in different languages. * @see VersionGroupFlavorText */ @JsonProperty("flavor_text_entries") val flavorTextEntries: List, - /** * A list of game indices relevent to this item by generation. * @see GenerationGameIndex */ @JsonProperty("game_indices") val gameIndices: List, - /** * The name of this item listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A set of sprites used to depict this item in the game. * @see ItemSprites */ @JsonProperty("sprites") val sprites: ItemSprites?, - /** * A list of Pokémon that might be found in the wild holding this item. * @see ItemHolderPokemon */ @JsonProperty("held_by_pokemon") val heldByPokemon: List, - /** * An evolution chain this item requires to produce a bay during mating. * @see APIResource @@ -120,18 +107,10 @@ class Item( */ @JsonProperty("baby_trigger_for") val babyTriggerFor: APIResource?, - /** * A list of the machines related to this item. * @see MachineVersionDetail */ @JsonProperty("machines") val machines: List - -) { - override fun toString(): String { - return "Item(id=$id, name='$name', cost=$cost, flingPower=$flingPower, flingEffect=$flingEffect, attributes=$attributes, " + - "category=$category, effectEntries=$effectEntries, flavorTextEntries=$flavorTextEntries, gameIndices=$gameIndices, " + - "names=$names, sprites=$sprites, heldByPokemon=$heldByPokemon, babyTriggerFor=$babyTriggerFor, machines=$machines)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/items/ItemAttribute.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemAttribute.kt similarity index 78% rename from src/main/kotlin/entity/items/ItemAttribute.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemAttribute.kt index 9199f89..424ecfb 100644 --- a/src/main/kotlin/entity/items/ItemAttribute.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemAttribute.kt @@ -1,9 +1,10 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Item attributes define particular aspects of items, e.g. "usable in battle" or "consumable". @@ -15,20 +16,17 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class ItemAttribute( - +data class ItemAttribute( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource */ @JsonProperty("name") val name: String, - /** * A list of items that have this attribute. * @see NamedApiResource @@ -36,22 +34,16 @@ class ItemAttribute( */ @JsonProperty("items") val items: Array>, - /** * The name of this item attribute listed in different languages. * @see Name */ @JsonProperty("names") val names: Array, - /** * The description of this item attribute listed in different languages. * @see Description */ @JsonProperty("descriptions") val descriptions: Array -) { - override fun toString(): String { - return "ItemAttribute(id=$id, name='$name', items=$items, names=$names, descriptions=$descriptions)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/items/ItemCategory.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemCategory.kt similarity index 81% rename from src/main/kotlin/entity/items/ItemCategory.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemCategory.kt index 6d2b7b7..d34708b 100644 --- a/src/main/kotlin/entity/items/ItemCategory.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemCategory.kt @@ -1,8 +1,9 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Item categories determine where items will be placed in the players bag. @@ -14,20 +15,17 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class ItemCategory( - +data class ItemCategory( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource */ @JsonProperty("name") val name: String, - /** * A list of items that have this attribute. * @see NamedApiResource @@ -35,14 +33,12 @@ class ItemCategory( */ @JsonProperty("items") val items: List>, - /** * The name of this item attribute listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * The pocket items in this category would be put in. * @see NamedApiResource @@ -50,8 +46,4 @@ class ItemCategory( */ @JsonProperty("pocket") val pocket: NamedApiResource -) { - override fun toString(): String { - return "ItemCategory(id=$id, name='$name', items=$items, names=$names, pocket=$pocket)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/items/ItemFlingEffect.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemFlingEffect.kt similarity index 76% rename from src/main/kotlin/entity/items/ItemFlingEffect.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemFlingEffect.kt index c7a202c..6ed7e47 100644 --- a/src/main/kotlin/entity/items/ItemFlingEffect.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemFlingEffect.kt @@ -1,8 +1,9 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Effect -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Effect +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * The various effects of the move "Fling" when used with different items. @@ -13,27 +14,23 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class ItemFlingEffect( - +data class ItemFlingEffect( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The result of this fling effect listed in different languages. * @see Effect */ @JsonProperty("effect_entries") val effectEntries: List, - /** * A list of items that have this fling effect. * @see NamedApiResource @@ -41,8 +38,4 @@ class ItemFlingEffect( */ @JsonProperty("items") val items: List> -) { - override fun toString(): String { - return "ItemFlingEffect(id=$id, name='$name', effectEntries=$effectEntries, items=$items)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/items/ItemHolderPokemon.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemHolderPokemon.kt similarity index 81% rename from src/main/kotlin/entity/items/ItemHolderPokemon.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemHolderPokemon.kt index 90b1af3..e1d2597 100644 --- a/src/main/kotlin/entity/items/ItemHolderPokemon.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemHolderPokemon.kt @@ -1,8 +1,8 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.pokemon.Pokemon +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.pokemon.Pokemon /** * @see Documentation of PokeApi @@ -19,7 +19,6 @@ class ItemHolderPokemon( */ @JsonProperty("pokemon") val pokemon: NamedApiResource, - /** * The details for the version that this item is held in by the Pokémon. * @see ItemHolderPokemonVersionDetail diff --git a/src/main/kotlin/entity/items/ItemHolderPokemonVersionDetail.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemHolderPokemonVersionDetail.kt similarity index 70% rename from src/main/kotlin/entity/items/ItemHolderPokemonVersionDetail.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemHolderPokemonVersionDetail.kt index 0753d24..dd136e1 100644 --- a/src/main/kotlin/entity/items/ItemHolderPokemonVersionDetail.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemHolderPokemonVersionDetail.kt @@ -1,7 +1,7 @@ -package entity.items +package fr.tykok.pokeapi.entities.items -import entity.common.NamedApiResource -import entity.games.Version +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Version /** * @see Documentation of PokeApi @@ -10,13 +10,11 @@ import entity.games.Version * @version 1.0.0 * @since 2022-08-27 */ -class ItemHolderPokemonVersionDetail( - +data class ItemHolderPokemonVersionDetail( /** * How often this Pokémon holds this item in this version. */ val rarity: Number, - /** * The version that this item is held in by the Pokémon. * @see NamedApiResource diff --git a/src/main/kotlin/entity/items/ItemPocket.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemPocket.kt similarity index 79% rename from src/main/kotlin/entity/items/ItemPocket.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemPocket.kt index 4b35ef2..e491599 100644 --- a/src/main/kotlin/entity/items/ItemPocket.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemPocket.kt @@ -1,8 +1,9 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Pockets within the players bag used for storing items by category. @@ -14,20 +15,17 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class ItemPocket( - +data class ItemPocket( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * A list of item categories that are relevant to this item pocket. * @see NamedApiResource @@ -35,15 +33,10 @@ class ItemPocket( */ @JsonProperty("categories") val categories: List>, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List -) { - override fun toString(): String { - return "ItemPocket(id=$id, name='$name', categories=$categories, names=$names)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/items/ItemSprites.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemSprites.kt similarity index 89% rename from src/main/kotlin/entity/items/ItemSprites.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemSprites.kt index f15f602..f0d8bd8 100644 --- a/src/main/kotlin/entity/items/ItemSprites.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/items/ItemSprites.kt @@ -1,4 +1,4 @@ -package entity.items +package fr.tykok.pokeapi.entities.items import com.fasterxml.jackson.annotation.JsonProperty @@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty * @version 1.0.0 * @since 2022-08-27 */ -class ItemSprites( +data class ItemSprites( /** * The default depiction of this item. */ diff --git a/src/main/kotlin/entity/locations/EncounterMethodRate.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/EncounterMethodRate.kt similarity index 70% rename from src/main/kotlin/entity/locations/EncounterMethodRate.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/EncounterMethodRate.kt index c6379cf..d2495c8 100644 --- a/src/main/kotlin/entity/locations/EncounterMethodRate.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/EncounterMethodRate.kt @@ -1,8 +1,8 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.encounters.EncounterMethod +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.encounters.EncounterMethod /** * @see Documentation of PokeApi @@ -11,8 +11,7 @@ import entity.encounters.EncounterMethod * @version 1.0.0 * @since 2022-08-27 */ -class EncounterMethodRate( - +data class EncounterMethodRate( /** * The method in which Pokémon may be encountered in an area.. * @see NamedApiResource @@ -20,15 +19,10 @@ class EncounterMethodRate( */ @JsonProperty("encounter_method") val encounterMethod: NamedApiResource, - /** * The chance of the encounter to occur on a version of the game. * @see EncounterVersionDetails */ @JsonProperty("version_details") val versionDetails: List -) { - override fun toString(): String { - return "EncounterMethodRate(encounterMethod=$encounterMethod, versionDetails=$versionDetails)" - } -} +) diff --git a/src/main/kotlin/entity/locations/EncounterVersionDetails.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/EncounterVersionDetails.kt similarity index 69% rename from src/main/kotlin/entity/locations/EncounterVersionDetails.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/EncounterVersionDetails.kt index 3fd21bc..dd9db25 100644 --- a/src/main/kotlin/entity/locations/EncounterVersionDetails.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/EncounterVersionDetails.kt @@ -1,8 +1,8 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.games.Version +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Version /** * @see Documentation of PokeApi @@ -11,14 +11,12 @@ import entity.games.Version * @version 1.0.0 * @since 2022-08-27 */ -class EncounterVersionDetails( - +data class EncounterVersionDetails( /** * The chance of an encounter to occur. */ @JsonProperty("rate") val rate: Number, - /** * The version of the game in which the encounter can occur with the given chance. * @see NamedApiResource @@ -26,8 +24,4 @@ class EncounterVersionDetails( */ @JsonProperty("version") val version: NamedApiResource -) { - override fun toString(): String { - return "EncounterVersionDetails(rate=$rate, version=$version)" - } -} +) diff --git a/src/main/kotlin/entity/locations/Location.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/Location.kt similarity index 81% rename from src/main/kotlin/entity/locations/Location.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/Location.kt index 819ee50..d74bb45 100644 --- a/src/main/kotlin/entity/locations/Location.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/Location.kt @@ -1,9 +1,10 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.GenerationGameIndex -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.GenerationGameIndex +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Locations that can be visited within the games. Locations make up sizable portions of regions, like cities or routes. @@ -15,19 +16,17 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class Location( +data class Location( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The region this location can be found in. * @see NamedApiResource @@ -35,21 +34,18 @@ class Location( */ @JsonProperty("region") val region: NamedApiResource, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of game indices relevent to this location by generation. * @see GenerationGameIndex */ @JsonProperty("game_indices") val gameIndices: List, - /** * Areas that can be found within this location. * @see NamedApiResource @@ -57,8 +53,4 @@ class Location( */ @JsonProperty("areas") val areas: List> -) { - override fun toString(): String { - return "Location(id=$id, name='$name', region=$region, names=$names, gameIndices=$gameIndices, areas=$areas)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/locations/LocationArea.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/LocationArea.kt similarity index 82% rename from src/main/kotlin/entity/locations/LocationArea.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/LocationArea.kt index 7a9122e..46f568a 100644 --- a/src/main/kotlin/entity/locations/LocationArea.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/LocationArea.kt @@ -1,8 +1,9 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Location areas are sections of areas, such as floors in a building or cave. @@ -15,26 +16,22 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class LocationArea( - +data class LocationArea( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The internal id of an API resource within game data. */ @JsonProperty("game_index") val gameIndex: Number, - /** * A list of methods in which Pokémon may be encountered in this area and how likely the method * will occur depending on the version of the game. @@ -42,7 +39,6 @@ class LocationArea( */ @JsonProperty("encounter_method_rates") val encounterMethodRates: List, - /** * The region this location area can be found in. * @see NamedApiResource @@ -50,23 +46,16 @@ class LocationArea( */ @JsonProperty("location") val location: NamedApiResource, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of Pokémon that can be encountered in this area along with version specific details about the encounter. * @see PokemonEncounter */ @JsonProperty("pokemon_encounters") val pokemonEncounters: List -) { - override fun toString(): String { - return "LocationArea(id=$id, name=$name, gameIndex=$gameIndex, encounterMethodRates=$encounterMethodRates, location=$location, " + - "names=$names, pokemonEncounters=$pokemonEncounters)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/locations/PalParkArea.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/PalParkArea.kt similarity index 77% rename from src/main/kotlin/entity/locations/PalParkArea.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/PalParkArea.kt index a1c063a..7713ab7 100644 --- a/src/main/kotlin/entity/locations/PalParkArea.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/PalParkArea.kt @@ -1,7 +1,8 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name /** * @see Documentation of PokeApi @@ -10,34 +11,27 @@ import entity.common.Name * @version 1.0.0 * @since 2022-08-27 */ -class PalParkArea( +data class PalParkArea( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of Pokémon encountered in thi pal park area along with details. * @see PalParkEncounterSpecies */ @JsonProperty("pokemon_encounters") val pokemonEncounters: List -) { - override fun toString(): String { - return "PalParkArea(id=$id, name='$name', names=$names, pokemonEncounters=$pokemonEncounters)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/locations/PalParkEncounterSpecies.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/PalParkEncounterSpecies.kt similarity index 71% rename from src/main/kotlin/entity/locations/PalParkEncounterSpecies.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/PalParkEncounterSpecies.kt index 5d55987..2956e33 100644 --- a/src/main/kotlin/entity/locations/PalParkEncounterSpecies.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/PalParkEncounterSpecies.kt @@ -1,8 +1,8 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies /** * @see Documentation of PokeApi @@ -11,20 +11,17 @@ import entity.pokemon.PokemonSpecies * @version 1.0.0 * @since 2022-08-27 */ -class PalParkEncounterSpecies( - +data class PalParkEncounterSpecies( /** * The base score given to the player when this Pokémon is caught during a pal park run */ @JsonProperty("base_score") val baseScore: Number, - /** * The base rate for encountering this Pokémon in this pal park area */ @JsonProperty("rate") val rate: Number, - /** * The Pokémon species being encountered * @see NamedApiResource @@ -32,8 +29,4 @@ class PalParkEncounterSpecies( */ @JsonProperty("pokemon_species") val pokemonSpecies: NamedApiResource -) { - override fun toString(): String { - return "PalParkEncounterSpecies(baseScore=$baseScore, rate=$rate, pokemonSpecies=$pokemonSpecies)" - } -} +) diff --git a/src/main/kotlin/entity/locations/PokemonEncounter.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/PokemonEncounter.kt similarity index 68% rename from src/main/kotlin/entity/locations/PokemonEncounter.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/PokemonEncounter.kt index 276d22f..55ba681 100644 --- a/src/main/kotlin/entity/locations/PokemonEncounter.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/PokemonEncounter.kt @@ -1,9 +1,9 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.common.VersionEncounterDetail -import entity.pokemon.Pokemon +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VersionEncounterDetail +import fr.tykok.pokeapi.entities.pokemon.Pokemon /** * @see Documentation of PokeApi @@ -12,7 +12,7 @@ import entity.pokemon.Pokemon * @version 1.0.0 * @since 2022-08-27 */ -class PokemonEncounter( +data class PokemonEncounter( /** * The Pokémon being encountered. * @see NamedApiResource @@ -20,15 +20,10 @@ class PokemonEncounter( */ @JsonProperty("pokemon") val pokemon: NamedApiResource, - /** * A list of versions and encounters with Pokémon that might happen in the referenced location area. * @see VersionEncounterDetail */ @JsonProperty("version_details") val versionDetails: List -) { - override fun toString(): String { - return "PokemonEncounter(pokemon=$pokemon, versionDetails=$versionDetails)" - } -} +) diff --git a/src/main/kotlin/entity/locations/Region.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/Region.kt similarity index 80% rename from src/main/kotlin/entity/locations/Region.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/locations/Region.kt index 5557854..8c6d330 100644 --- a/src/main/kotlin/entity/locations/Region.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/locations/Region.kt @@ -1,11 +1,12 @@ -package entity.locations +package fr.tykok.pokeapi.entities.locations import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource -import entity.games.Generation -import entity.games.Pokedex -import entity.games.VersionGroup +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Generation +import fr.tykok.pokeapi.entities.games.Pokedex +import fr.tykok.pokeapi.entities.games.VersionGroup /** * A region is an organized area of the Pokémon world. Most often, the main difference between regions is the @@ -18,14 +19,12 @@ import entity.games.VersionGroup * @version 1.0.0 * @since 2022-08-27 */ -class Region( - +data class Region( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * A list of locations that can be found in this region. * @see NamedApiResource @@ -33,20 +32,17 @@ class Region( */ @JsonProperty("locations") val locations: List>, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * The generation this region was introduced in. * @see NamedApiResource @@ -54,7 +50,6 @@ class Region( */ @JsonProperty("main_generation") val mainGeneration: NamedApiResource, - /** * A list of pokédexes that catalogue Pokémon in this region. * @see Pokedex @@ -62,7 +57,6 @@ class Region( */ @JsonProperty("pokedexes") val pokedexes: List>, - /** * A list of version groups where this region can be visited. * @see NamedApiResource @@ -70,8 +64,4 @@ class Region( */ @JsonProperty("version_groups") val versionGroups: List> -) { - override fun toString(): String { - return "Region(id=$id, locations=$locations, name='$name', names=$names, mainGeneration=$mainGeneration, pokedexes=$pokedexes, versionGroups=$versionGroups)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/machines/Machine.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/machines/Machine.kt similarity index 76% rename from src/main/kotlin/entity/machines/Machine.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/machines/Machine.kt index 28f0b87..e021a02 100644 --- a/src/main/kotlin/entity/machines/Machine.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/machines/Machine.kt @@ -1,10 +1,11 @@ -package entity.machines +package fr.tykok.pokeapi.entities.machines import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.games.VersionGroup -import entity.items.Item -import entity.moves.Move +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.items.Item +import fr.tykok.pokeapi.entities.moves.Move /** * Machines are the representation of items that teach moves to Pokémon. @@ -16,14 +17,12 @@ import entity.moves.Move * @version 1.0.0 * @since 2022-08-27 */ -class Machine( - +data class Machine( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The TM or HM item that corresponds to this machine. * @see NamedApiResource @@ -31,7 +30,6 @@ class Machine( */ @JsonProperty("item") val item: NamedApiResource, - /** * The move that is taught by this machine. * @see NamedApiResource @@ -39,7 +37,6 @@ class Machine( */ @JsonProperty("move") val move: NamedApiResource, - /** * The version group that this machine applies to. * @see NamedApiResource @@ -47,8 +44,4 @@ class Machine( */ @JsonProperty("version_group") val versionGroup: NamedApiResource -) { - override fun toString(): String { - return "Machine(id=$id, item=$item, move=$move, versionGroup=$versionGroup)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/ContestComboDetail.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/ContestComboDetail.kt similarity index 73% rename from src/main/kotlin/entity/moves/ContestComboDetail.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/ContestComboDetail.kt index 7d185ad..694afd6 100644 --- a/src/main/kotlin/entity/moves/ContestComboDetail.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/ContestComboDetail.kt @@ -1,7 +1,7 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @see Documentation of PokeApi @@ -10,8 +10,7 @@ import entity.common.NamedApiResource * @version 1.0.0 * @since 2022-08-27 */ -class ContestComboDetail( - +data class ContestComboDetail( /** * A list of moves to use before this move. * @see NamedApiResource @@ -19,7 +18,6 @@ class ContestComboDetail( */ @JsonProperty("use_before") val useBefore: List>? = null, - /** * A list of moves to use after this move. * @see NamedApiResource @@ -27,9 +25,4 @@ class ContestComboDetail( */ @JsonProperty("use_after") val useAfter: List>? = null - -) { - override fun toString(): String { - return "ContestComboDetail(useBefore=$useBefore, useAfter=$useAfter)" - } -} +) diff --git a/src/main/kotlin/entity/moves/ContestComboSets.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/ContestComboSets.kt similarity index 90% rename from src/main/kotlin/entity/moves/ContestComboSets.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/ContestComboSets.kt index d906dc6..e02f1b7 100644 --- a/src/main/kotlin/entity/moves/ContestComboSets.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/ContestComboSets.kt @@ -1,4 +1,4 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty @@ -9,15 +9,13 @@ import com.fasterxml.jackson.annotation.JsonProperty * @version 1.0.0 * @since 2022-08-27 */ -class ContestComboSets( - +data class ContestComboSets( /** * A detail of moves this move can be used before or after, granting additional appeal points in contests. * @see ContestComboDetail */ @JsonProperty("normal") val normal: ContestComboDetail, - /** * A detail of moves this move can be used before or after, granting additional appeal points in super contests. * @see ContestComboDetail diff --git a/src/main/kotlin/entity/moves/Move.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/Move.kt similarity index 82% rename from src/main/kotlin/entity/moves/Move.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/Move.kt index d27196c..52ca610 100644 --- a/src/main/kotlin/entity/moves/Move.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/Move.kt @@ -1,16 +1,17 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.APIResource -import entity.common.MachineVersionDetail -import entity.common.Name -import entity.common.NamedApiResource -import entity.common.VerboseEffect -import entity.contests.ContestType -import entity.contests.SuperContestEffects -import entity.games.Generation -import entity.pokemon.Pokemon -import entity.pokemon.Type +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.APIResource +import fr.tykok.pokeapi.entities.common.MachineVersionDetail +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VerboseEffect +import fr.tykok.pokeapi.entities.contests.ContestType +import fr.tykok.pokeapi.entities.contests.SuperContestEffects +import fr.tykok.pokeapi.entities.games.Generation +import fr.tykok.pokeapi.entities.pokemon.Pokemon +import fr.tykok.pokeapi.entities.pokemon.Type /** * Moves are the skills of Pokémon in battle. In battle, a Pokémon uses one move each turn. @@ -24,56 +25,48 @@ import entity.pokemon.Type * @version 1.0.0 * @since 2022-08-27 */ -class Move( +data class Move( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The percent value of how likely this move is to be successful. */ @JsonProperty("accuracy") val accuracy: Number, - /** * The percent value of how likely it is this moves effect will happen. */ @JsonProperty("effect_chance") val effectChance: Number? = null, - /** * Power points. The number of times this move can be used. */ @JsonProperty("pp") val pp: Number, - /** * A value between -8 and 8. Sets the order in which moves are executed during battle. See Bulbapedia for greater detail. */ @JsonProperty("priority") val priority: Number, - /** * The base power of this move with a value of 0 if it does not have a base power. */ @JsonProperty("power") val power: Number, - /** * A detail of normal and super contest combos that require this move. * @see ContestComboSets */ @JsonProperty("contest_combos") val contestCombos: ContestComboSets, - /** * The type of appeal this move gives a Pokémon when used in a contest. * @see ContestType @@ -81,7 +74,6 @@ class Move( */ @JsonProperty("contest_type") val contestType: NamedApiResource, - /** * The effect the move has when used in a contest. * @see APIResource @@ -89,7 +81,6 @@ class Move( */ @JsonProperty("contest_effect") val contestEffect: APIResource, - /** * The type of damage the move inflicts on the target, e.g. physical. * @ee NamedApiResource @@ -97,21 +88,18 @@ class Move( */ @JsonProperty("damage_class") val damageClass: NamedApiResource, - /** * The effect of this move listed in different languages. * @see VerboseEffect */ @JsonProperty("effect_entries") val effectEntries: List, - /** * The list of previous effects this move has had across version groups of the games. * @see SuperContestEffects */ @JsonProperty("effect_changes") val effectChanges: List, - /** * List of Pokemon that can learn the move * @see NamedApiResource @@ -119,14 +107,12 @@ class Move( */ @JsonProperty("learned_by_pokemon") val learnedByPokemon: List>, - /** * The flavor text of this move listed in different languages. * @see MoveFlavorText */ @JsonProperty("flavor_text_entries") val flavorTextEntries: List, - /** * The generation in which this move was introduced. * @see NamedApiResource @@ -134,42 +120,36 @@ class Move( */ @JsonProperty("generation") val generation: NamedApiResource, - /** * A list of the machines that teach this move. * @see MachineVersionDetail */ @JsonProperty("machines") val machines: List, - /** * Metadata about this move * @see MoveMetaData */ @JsonProperty("meta") val meta: MoveMetaData, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of move resource value changes across version groups of the game. * @see PastMoveStatValues */ @JsonProperty("past_values") val pastValues: List, - /** * A list of stats this moves effects and how much it effects them. * @see MoveStatChange */ @JsonProperty("stat_changes") val statChanges: List, - /** * The effect the move has when used in a super contest. * @see APIResource @@ -177,7 +157,6 @@ class Move( */ @JsonProperty("super_contest_effect") val superContestEffect: APIResource, - /** * The type of target that will receive the effects of the attack. * @see NamedApiResource @@ -185,7 +164,6 @@ class Move( */ @JsonProperty("target") val target: NamedApiResource, - /** * The elemental type of this move. * @see NamedApiResource @@ -193,8 +171,4 @@ class Move( */ @JsonProperty("type") val type: NamedApiResource -) { - override fun toString(): String { - return "Move(id=$id, name='$name', accuracy=$accuracy, effectChance=$effectChance, pp=$pp, priority=$priority, power=$power, contestCombos=$contestCombos, contestType=$contestType, contestEffect=$contestEffect, damageClass=$damageClass, effectEntries=$effectEntries, effectChanges=$effectChanges, learnedByPokemon=$learnedByPokemon, flavorTextEntries=$flavorTextEntries, generation=$generation, machines=$machines, meta=$meta, names=$names, pastValues=$pastValues, statChanges=$statChanges, superContestEffect=$superContestEffect, target=$target, type=$type)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/MoveAilment.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveAilment.kt similarity index 73% rename from src/main/kotlin/entity/moves/MoveAilment.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveAilment.kt index ea5bc65..d69c57b 100644 --- a/src/main/kotlin/entity/moves/MoveAilment.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveAilment.kt @@ -1,8 +1,9 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @author Tykok @@ -10,20 +11,17 @@ import entity.common.NamedApiResource * @since 2022-08-30 * */ -class MoveAilment( - +data class MoveAilment( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * A list of moves that cause this ailment. * @see NamedApiResource @@ -31,16 +29,10 @@ class MoveAilment( */ @JsonProperty("moves") val moves: List>, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List - -) { - override fun toString(): String { - return "MoveAilment(id=$id, name='$name', moves=$moves, names=$names)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/MoveBattleStyle.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveBattleStyle.kt similarity index 71% rename from src/main/kotlin/entity/moves/MoveBattleStyle.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveBattleStyle.kt index ab323b4..6d7a847 100644 --- a/src/main/kotlin/entity/moves/MoveBattleStyle.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveBattleStyle.kt @@ -1,7 +1,8 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name /** * @author Tykok @@ -9,28 +10,21 @@ import entity.common.Name * @since 2022-08-30 * */ -class MoveBattleStyle( +data class MoveBattleStyle( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List - -) { - override fun toString(): String { - return "MoveBattleStyle(id=$id, name='$name', names=$names)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/MoveCategory.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveCategory.kt similarity index 68% rename from src/main/kotlin/entity/moves/MoveCategory.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveCategory.kt index b8f63d4..015c19f 100644 --- a/src/main/kotlin/entity/moves/MoveCategory.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveCategory.kt @@ -1,7 +1,8 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves -import entity.common.Description -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @author Tykok @@ -9,28 +10,24 @@ import entity.common.NamedApiResource * @since 2022-08-30 * */ -class MoveCategory( - +data class MoveCategory( /** * The identifier for this resource. */ val id: Number, - /** * The name for this resource. */ val name: String, - /** * A list of moves that fall into this category. * @see NamedApiResource * @see Move */ val moves: Array>, - /** * The description of this resource listed in different languages. * @see Move */ val descriptions: Array -) +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/MoveDamageClass.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveDamageClass.kt similarity index 73% rename from src/main/kotlin/entity/moves/MoveDamageClass.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveDamageClass.kt index d4777b8..6bea97c 100644 --- a/src/main/kotlin/entity/moves/MoveDamageClass.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveDamageClass.kt @@ -1,9 +1,10 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @author Tykok @@ -11,27 +12,23 @@ import entity.common.NamedApiResource * @since 2022-08-30 * */ -class MoveDamageClass( - +data class MoveDamageClass( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The description of this resource listed in different languages. * @see Description */ @JsonProperty("descriptions") val descriptions: List, - /** * A list of moves that fall into this damage class. * @see NamedApiResource @@ -39,15 +36,10 @@ class MoveDamageClass( */ @JsonProperty("moves") val moves: List>, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List -) { - override fun toString(): String { - return "MoveDamageClass(id=$id, name='$name', descriptions=$descriptions, moves=$moves, names=$names)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/MoveFlavorText.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveFlavorText.kt similarity index 68% rename from src/main/kotlin/entity/moves/MoveFlavorText.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveFlavorText.kt index a081606..8e943bf 100644 --- a/src/main/kotlin/entity/moves/MoveFlavorText.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveFlavorText.kt @@ -1,23 +1,21 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.games.VersionGroup -import entity.utility.Language +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.utility.Language /** * @author Tykok * @version 1.0.0 * @since 2022-08-27 */ -class MoveFlavorText( - +data class MoveFlavorText( /** * The localized flavor text for an api resource in a specific language. */ @JsonProperty("flavor_text") val flavorText: String, - /** * The language this name is in. * @see NamedApiResource @@ -25,7 +23,6 @@ class MoveFlavorText( */ @JsonProperty("language") val language: NamedApiResource, - /** * The version group that uses this flavor text. * @see NamedApiResource @@ -33,9 +30,4 @@ class MoveFlavorText( */ @JsonProperty("version_group") val versionGroup: NamedApiResource - -) { - override fun toString(): String { - return "MoveFlavorText(flavorText='$flavorText', language=$language, versionGroup=$versionGroup)" - } -} +) diff --git a/src/main/kotlin/entity/moves/MoveLearnMethod.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveLearnMethod.kt similarity index 71% rename from src/main/kotlin/entity/moves/MoveLearnMethod.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveLearnMethod.kt index ade95d2..e7ca904 100644 --- a/src/main/kotlin/entity/moves/MoveLearnMethod.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveLearnMethod.kt @@ -1,10 +1,11 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.Name -import entity.common.NamedApiResource -import entity.games.VersionGroup +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.VersionGroup /** * @author Tykok @@ -12,34 +13,29 @@ import entity.games.VersionGroup * @since 2022-08-30 * */ -class MoveLearnMethod( - +data class MoveLearnMethod( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The description of this resource listed in different languages. * @see Description */ @JsonProperty("descriptions") val descriptions: List, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of version groups where moves can be learned through this method. * @see NamedApiResource @@ -47,9 +43,4 @@ class MoveLearnMethod( */ @JsonProperty("version_groups") val versionGroups: List> - -) { - override fun toString(): String { - return "MoveLearnMethod(id=$id, name='$name', descriptions=$descriptions, names=$names, versionGroups=$versionGroups)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/MoveMetaData.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveMetaData.kt similarity index 83% rename from src/main/kotlin/entity/moves/MoveMetaData.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveMetaData.kt index b7084b5..5c4b608 100644 --- a/src/main/kotlin/entity/moves/MoveMetaData.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveMetaData.kt @@ -1,15 +1,14 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @author Tykok * @version 1.0.0 * @since 2022-08-27 */ -class MoveMetaData( - +data class MoveMetaData( /** * The status ailment this move inflicts on its target. * @see MoveAilment @@ -17,7 +16,6 @@ class MoveMetaData( */ @JsonProperty("ailment") val ailment: NamedApiResource, - /** * The category of move this move falls under, e.g. damage or ailment. * @see MoveCategory @@ -25,69 +23,54 @@ class MoveMetaData( */ @JsonProperty("category") val category: NamedApiResource, - /** * The minimum number of times this move hits. Null if it always only hits once. */ @JsonProperty("min_hits") val minHits: Number? = null, - /** * The maximum number of times this move hits. Null if it always only hits once. */ @JsonProperty("max_hits") val maxHits: Number? = null, - /** * The minimum number of turns this move continues to take effect. Null if it always only lasts one turn. */ @JsonProperty("min_turns") val minTurns: Number? = null, - /** * The maximum number of turns this move continues to take effect. Null if it always only lasts one turn. */ @JsonProperty("max_turns") val maxTurns: Number? = null, - /** * HP drain (if positive) or Recoil damage (if negative), in percent of damage done. */ @JsonProperty("drain") val drain: Number, - /** * The amount of hp gained by the attacking Pokemon, in percent of it's maximum HP. */ @JsonProperty("healing") val healing: Number, - /** * Critical hit rate bonus. */ @JsonProperty("crit_rate") val critRate: Number, - /** * The likelihood this attack will cause an ailment. */ @JsonProperty("ailment_chance") val ailmentChance: Number, - /** * The likelihood this attack will cause the target Pokémon to flinch. */ @JsonProperty("flinch_chance") val flinchChance: Number, - /** * The likelihood this attack will cause a stat change in the target Pokémon. */ @JsonProperty("stat_chance") val statChance: Number? = null - -) { - override fun toString(): String { - return "MoveMetaData(ailment=$ailment, category=$category, minHits=$minHits, maxHits=$maxHits, minTurns=$minTurns, maxTurns=$maxTurns, drain=$drain, healing=$healing, crit_rate=$critRate, ailmentChance=$ailmentChance, flinchChance=$flinchChance, statChance=$statChance)" - } -} +) diff --git a/src/main/kotlin/entity/moves/MoveStatChange.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveStatChange.kt similarity index 63% rename from src/main/kotlin/entity/moves/MoveStatChange.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveStatChange.kt index 6b360c6..305ee0f 100644 --- a/src/main/kotlin/entity/moves/MoveStatChange.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveStatChange.kt @@ -1,21 +1,20 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.pokemon.Stat +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.pokemon.Stat /** * @author Tykok * @version 1.0.0 * @since 2022-08-27 */ -class MoveStatChange( +data class MoveStatChange( /** * The amount of change. */ @JsonProperty("change") val change: Number, - /** * The stat being affected. * @see NamedApiResource @@ -23,8 +22,4 @@ class MoveStatChange( */ @JsonProperty("stat") val stat: NamedApiResource -) { - override fun toString(): String { - return "MoveStatChange(change=$change, stat=$stat)" - } -} +) diff --git a/src/main/kotlin/entity/moves/MoveTarget.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveTarget.kt similarity index 74% rename from src/main/kotlin/entity/moves/MoveTarget.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveTarget.kt index 238c899..4f817d4 100644 --- a/src/main/kotlin/entity/moves/MoveTarget.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/MoveTarget.kt @@ -1,9 +1,10 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @author Tykok @@ -11,27 +12,23 @@ import entity.common.NamedApiResource * @since 2022-08-30 * */ -class MoveTarget( - +data class MoveTarget( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The description of this resource listed in different languages. * @see Description */ @JsonProperty("descriptions") val descriptions: List, - /** * A list of moves that that are directed at this target. * @see NamedApiResource @@ -39,16 +36,10 @@ class MoveTarget( */ @JsonProperty("moves") val moves: List>, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List - -) { - override fun toString(): String { - return "MoveTarget(id=$id, name='$name', descriptions=$descriptions, moves=$moves, names=$names)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/moves/PastMoveStatValues.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/PastMoveStatValues.kt similarity index 75% rename from src/main/kotlin/entity/moves/PastMoveStatValues.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/moves/PastMoveStatValues.kt index 0fd68c2..94335c6 100644 --- a/src/main/kotlin/entity/moves/PastMoveStatValues.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/moves/PastMoveStatValues.kt @@ -1,49 +1,43 @@ -package entity.moves +package fr.tykok.pokeapi.entities.moves import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.common.VerboseEffect -import entity.games.VersionGroup -import entity.pokemon.Type +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VerboseEffect +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.pokemon.Type /** * @author Tykok * @version 1.0.0 * @since 2022-08-27 */ -class PastMoveStatValues( - +data class PastMoveStatValues( /** * The percent value of how likely this move is to be successful. */ @JsonProperty("accuracy") val accuracy: Number, - /** * The percent value of how likely it is this moves effect will take effect. */ @JsonProperty("effect_chance") val effectChance: Number, - /** * The base power of this move with a value of 0 if it does not have a base power. */ @JsonProperty("power") val power: Number, - /** * Power points. The number of times this move can be used. */ @JsonProperty("pp") val pp: Number, - /** * The effect of this move listed in different languages. * @see VerboseEffect */ @JsonProperty("effect_entries") val effectEntries: List, - /** * The elemental type of this move. * @see NamedApiResource @@ -51,7 +45,6 @@ class PastMoveStatValues( */ @JsonProperty("type") val type: NamedApiResource, - /** * The version group in which these move stat values were in effect. * @see NamedApiResource @@ -59,8 +52,4 @@ class PastMoveStatValues( */ @JsonProperty("version_group") val versionGroup: NamedApiResource -) { - override fun toString(): String { - return "PastMoveStatValues(accuracy=$accuracy, effectChance=$effectChance, power=$power, pp=$pp, effectEntries=$effectEntries, type=$type, versionGroup=$versionGroup)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/Ability.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Ability.kt similarity index 72% rename from src/main/kotlin/entity/pokemon/Ability.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Ability.kt index fe9c0f9..e4b4310 100644 --- a/src/main/kotlin/entity/pokemon/Ability.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Ability.kt @@ -1,34 +1,31 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource -import entity.common.VerboseEffect -import entity.contests.SuperContestEffects -import entity.games.Generation +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VerboseEffect +import fr.tykok.pokeapi.entities.contests.SuperContestEffects +import fr.tykok.pokeapi.entities.games.Generation @JsonIgnoreProperties(ignoreUnknown = true) -class Ability( - +data class Ability( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * Whether this ability originated in the main series of the video games. */ @JsonProperty("is_main_series") val isMainSeries: Boolean, - /** * The generation this ability originated in. * @see Generation @@ -36,45 +33,34 @@ class Ability( */ @JsonProperty("generation") val generation: NamedApiResource, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array, - /** * The effect of this ability listed in different languages. * @see VerboseEffect */ @JsonProperty("effect_entries") val effectEntries: Array, - /** * The list of previous effects this ability has had across version groups. * @see SuperContestEffects */ @JsonProperty("effect_changes") val effectChanges: Array, - /** * The flavor text of this ability listed in different languages. * @see AbilityFlavorText */ @JsonProperty("flavor_text_entries") val flavorTextEntries: Array, - /** * A list of Pokémon that could potentially have this ability. * @see AbilityPokemon */ @JsonProperty("pokemon") val pokemon: Array -) { - override fun toString(): String = """ - Ability(id=$id, name='$name', isMainSeries=$isMainSeries, generation=$generation, names=${names.contentToString()}, - effectEntries=${effectEntries.contentToString()}, effectChanges=${effectChanges.contentToString()}, - flavorTextEntries=${flavorTextEntries.contentToString()}, pokemon=${pokemon.contentToString()}) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/AbilityFlavorText.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AbilityFlavorText.kt similarity index 72% rename from src/main/kotlin/entity/pokemon/AbilityFlavorText.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AbilityFlavorText.kt index 0d6a6fc..a9794ea 100644 --- a/src/main/kotlin/entity/pokemon/AbilityFlavorText.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AbilityFlavorText.kt @@ -1,17 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.games.VersionGroup -import entity.utility.Language +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.utility.Language -class AbilityFlavorText( +data class AbilityFlavorText( /** * The localized name for an API resource in a specific language. */ @JsonProperty("flavor_text") val flavorText: String, - /** * The language this text resource is in. * @see NamedApiResource @@ -19,7 +18,6 @@ class AbilityFlavorText( */ @JsonProperty("language") val language: NamedApiResource, - /** * The version group that uses this flavor text. * @see VersionGroup diff --git a/src/main/kotlin/entity/pokemon/AbilityPokemon.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AbilityPokemon.kt similarity index 83% rename from src/main/kotlin/entity/pokemon/AbilityPokemon.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AbilityPokemon.kt index 741709f..3cd3334 100644 --- a/src/main/kotlin/entity/pokemon/AbilityPokemon.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AbilityPokemon.kt @@ -1,22 +1,19 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource - -class AbilityPokemon( +import fr.tykok.pokeapi.entities.common.NamedApiResource +data class AbilityPokemon( /** * Whether or not this a hidden ability for the referenced Pokémon. */ @JsonProperty("is_hidden") val isHidden: Boolean, - /** * Pokémon have 3 ability 'slots' which hold references to possible abilities they could have. This is the slot of this ability for the referenced pokemon. */ @JsonProperty("slot") val slot: Number, - /** * The Pokémon this ability could belong to. * @see Pokemon diff --git a/src/main/kotlin/entity/pokemon/AwesomeName.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AwesomeName.kt similarity index 60% rename from src/main/kotlin/entity/pokemon/AwesomeName.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AwesomeName.kt index fd35d64..26aef69 100644 --- a/src/main/kotlin/entity/pokemon/AwesomeName.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/AwesomeName.kt @@ -1,21 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.utility.Language +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.utility.Language /** * @property awesomeName The localized "scientific" name for an API resource in a specific language. * @property language The language this "scientific" name is in. */ -class AwesomeName( +data class AwesomeName( @JsonProperty("awesome_name") val awesomeName: String, - @JsonProperty("language") val language: NamedApiResource -) { - override fun toString(): String { - return "AwesomeName(awesomeName='$awesomeName', language=$language)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/Characteristic.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Characteristic.kt similarity index 69% rename from src/main/kotlin/entity/pokemon/Characteristic.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Characteristic.kt index ce0714f..ca2611b 100644 --- a/src/main/kotlin/entity/pokemon/Characteristic.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Characteristic.kt @@ -1,38 +1,31 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.NamedApiResource -class Characteristic( +data class Characteristic( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The remainder of the highest stat/IV divided by 5. */ @JsonProperty("gene_modulo") val geneModulo: Number, - /** * The possible values of the highest stat that would result in a Pokémon recieving this characteristic when divided by 5. */ @JsonProperty("possible_values") val possibleValues: List, - @JsonProperty("descriptions") val descriptions: List, - /** * The stat which is affected by this characteristic. */ @JsonProperty("highest_stat") val highestStat: NamedApiResource -) { - override fun toString(): String { - return "Characteristic(id=$id, geneModulo=$geneModulo, possibleValues=$possibleValues), descriptions=$descriptions), highestStat=$highestStat)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/EggGroup.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/EggGroup.kt similarity index 72% rename from src/main/kotlin/entity/pokemon/EggGroup.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/EggGroup.kt index 62b8673..015eede 100644 --- a/src/main/kotlin/entity/pokemon/EggGroup.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/EggGroup.kt @@ -1,29 +1,27 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource -class EggGroup( +data class EggGroup( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List, - /** * A list of all Pokémon species that are members of this egg group. * @see PokemonSpecies @@ -31,8 +29,4 @@ class EggGroup( */ @JsonProperty("pokemon_species") val pokemonSpecies: List> -) { - override fun toString(): String { - return "EggGroup(id=$id, name='$name', names=$names, pokemonSpecies=$pokemonSpecies)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/Gender.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Gender.kt similarity index 72% rename from src/main/kotlin/entity/pokemon/Gender.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Gender.kt index 3ae36ea..5f21b68 100644 --- a/src/main/kotlin/entity/pokemon/Gender.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Gender.kt @@ -1,28 +1,26 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource -class Gender( +data class Gender( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * A list of Pokémon species that can be this gender and how likely it is that they will be. * @see PokemonSpeciesGender */ @JsonProperty("pokemon_species_details") val pokemonSpeciesDetails: List, - /** * A list of Pokémon species that required this gender in order for a Pokémon to evolve into them. * @see PokemonSpecies @@ -30,11 +28,4 @@ class Gender( */ @JsonProperty("required_for_evolution") val requiredForEvolution: List> -) { - override fun toString(): String { - return "id= $id" + - "name = $name" + - "pokemonSpeciesDetails = $pokemonSpeciesDetails" + - "requiredForEvolution = $requiredForEvolution" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/Genus.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Genus.kt similarity index 59% rename from src/main/kotlin/entity/pokemon/Genus.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Genus.kt index 1aba622..e93b0f5 100644 --- a/src/main/kotlin/entity/pokemon/Genus.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Genus.kt @@ -1,22 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.utility.Language +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.utility.Language /** * @property genus The localized genus for the referenced Pokémon species * @property language The language this genus is in. */ -class Genus( - +data class Genus( @JsonProperty("genus") val genus: String, - @JsonProperty("language") val language: NamedApiResource -) { - override fun toString(): String { - return "Genus(genus='$genus', language=$language)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/GrowthRate.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/GrowthRate.kt similarity index 75% rename from src/main/kotlin/entity/pokemon/GrowthRate.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/GrowthRate.kt index 1812b14..55e4272 100644 --- a/src/main/kotlin/entity/pokemon/GrowthRate.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/GrowthRate.kt @@ -1,49 +1,40 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Description -import entity.common.NamedApiResource - -class GrowthRate( +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.NamedApiResource +data class GrowthRate( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The formula used to calculate the rate at which the Pokémon species gains level. */ @JsonProperty("formula") val formula: String, - /** * The descriptions of this characteristic listed in different languages. */ @JsonProperty("descriptions") val descriptions: List, - /** * A list of levels and the amount of experienced needed to atain them based on this growth rate. */ @JsonProperty("levels") val levels: List, - /** * A list of Pokémon species that gain levels at this growth rate. * @see PokemonSpecies */ @JsonProperty("pokemon_species") val pokemonSpecies: List> -) { - override fun toString(): String { - return "GrowthRate(id=$id, name='$name', formula='$formula', descriptions=$descriptions, levels=$levels, pokemonSpecies=$pokemonSpecies)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/GrowthRateExperienceLevel.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/GrowthRateExperienceLevel.kt similarity index 60% rename from src/main/kotlin/entity/pokemon/GrowthRateExperienceLevel.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/GrowthRateExperienceLevel.kt index 4dadc77..b6bbf4e 100644 --- a/src/main/kotlin/entity/pokemon/GrowthRateExperienceLevel.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/GrowthRateExperienceLevel.kt @@ -1,23 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -class GrowthRateExperienceLevel( - +data class GrowthRateExperienceLevel( /** * The level gained. */ @JsonProperty("level") val level: Number, - /** * The amount of experience required to reach the referenced level. */ @JsonProperty("experience") val experience: Number -) { - - override fun toString(): String { - return "GrowthRateExperienceLevel(level=$level, experience=$experience)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/MoveBattleStylePreference.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveBattleStylePreference.kt similarity index 63% rename from src/main/kotlin/entity/pokemon/MoveBattleStylePreference.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveBattleStylePreference.kt index cf1eec9..f90f7c2 100644 --- a/src/main/kotlin/entity/pokemon/MoveBattleStylePreference.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveBattleStylePreference.kt @@ -1,22 +1,20 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.moves.MoveBattleStyle +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.moves.MoveBattleStyle -class MoveBattleStylePreference( +data class MoveBattleStylePreference( /** * Chance of using the move, in percent, if HP is under one half. */ @JsonProperty("low_hp_preference") val lowHpPreference: Number, - /** * Chance of using the move, in percent, if HP is over one half. */ @JsonProperty("high_hp_preference") val highHpPreference: Number, - /** * The move battle style. * @see MoveBattleStyle @@ -24,8 +22,4 @@ class MoveBattleStylePreference( */ @JsonProperty("move_battle_style") val moveBattleStyle: NamedApiResource -) { - override fun toString(): String { - return "MoveBattleStylePreference(lowHpPreference=$lowHpPreference, highHpPreference=$highHpPreference, moveBattleStyle=$moveBattleStyle)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/MoveStatAffect.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveStatAffect.kt similarity index 53% rename from src/main/kotlin/entity/pokemon/MoveStatAffect.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveStatAffect.kt index 4d8d226..b344be3 100644 --- a/src/main/kotlin/entity/pokemon/MoveStatAffect.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveStatAffect.kt @@ -1,13 +1,13 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon -import entity.common.NamedApiResource -import entity.moves.Move +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.moves.Move /** * @property change The maximum amount of change to the referenced stat. * @property move The move causing the change. */ -class MoveStatAffect( +data class MoveStatAffect( val change: Number, val move: NamedApiResource ) diff --git a/src/main/kotlin/entity/pokemon/MoveStatAffectSets.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveStatAffectSets.kt similarity index 66% rename from src/main/kotlin/entity/pokemon/MoveStatAffectSets.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveStatAffectSets.kt index 63114da..7109e18 100644 --- a/src/main/kotlin/entity/pokemon/MoveStatAffectSets.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/MoveStatAffectSets.kt @@ -1,4 +1,4 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty @@ -6,16 +6,9 @@ import com.fasterxml.jackson.annotation.JsonProperty * @property increase A list of moves and how they change the referenced stat. * @property decrease A list of moves and how they change the referenced stat. */ -class MoveStatAffectSets( - +data class MoveStatAffectSets( @JsonProperty("increase") val increase: List, - @JsonProperty("decrease") val decrease: List -) { - - override fun toString(): String { - return "MoveStatAffectSets(increase=$increase, decrease=$decrease)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/Nature.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Nature.kt similarity index 79% rename from src/main/kotlin/entity/pokemon/Nature.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Nature.kt index 32ce3ed..70414e8 100644 --- a/src/main/kotlin/entity/pokemon/Nature.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Nature.kt @@ -1,24 +1,22 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.berries.BerryFlavor -import entity.common.Name -import entity.common.NamedApiResource - -class Nature( +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.berries.BerryFlavor +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +data class Nature( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The stat decreased by 10% in Pokémon with this nature. * @see Stat @@ -26,7 +24,6 @@ class Nature( */ @JsonProperty("decreased_stat") val decreasedStat: NamedApiResource?, - /** * The stat increased by 10% in Pokémon with this nature. * @see Stat @@ -34,7 +31,6 @@ class Nature( */ @JsonProperty("increased_stat") val increasedStat: NamedApiResource?, - /** * The flavor hated by Pokémon with this nature. * @see BerryFlavor @@ -42,7 +38,6 @@ class Nature( */ @JsonProperty("hates_flavor") val hatesFlavor: NamedApiResource?, - /** * The flavor liked by Pokémon with this nature. * @see BerryFlavor @@ -50,30 +45,22 @@ class Nature( */ @JsonProperty("likes_flavor") val likesFlavor: NamedApiResource?, - /** * A list of Pokéathlon stats this nature effects and how much it effects them. * @see NatureStatChange */ @JsonProperty("pokeathlon_stat_changes") val pokeathlonStatChanges: List, - /** * A list of battle styles and how likely a Pokémon with this nature is to use them in the Battle Palace or Battle Tent. * @see MoveBattleStylePreference */ @JsonProperty("move_battle_style_preferences") val moveBattleStylePreferences: List, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: List - -) { - override fun toString(): String { - return "Nature(id=$id, name='$name', decreasedStat=$decreasedStat, increasedStat=$increasedStat, hatesFlavor=$hatesFlavor, likesFlavor=$likesFlavor, pokeathlonStatChanges=$pokeathlonStatChanges, moveBattleStylePreferences=$moveBattleStylePreferences, names=$names)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/NaturePokeathlonStatAffect.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NaturePokeathlonStatAffect.kt similarity index 60% rename from src/main/kotlin/entity/pokemon/NaturePokeathlonStatAffect.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NaturePokeathlonStatAffect.kt index f1529f1..4ee7d59 100644 --- a/src/main/kotlin/entity/pokemon/NaturePokeathlonStatAffect.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NaturePokeathlonStatAffect.kt @@ -1,23 +1,18 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class NaturePokeathlonStatAffect( +data class NaturePokeathlonStatAffect( /** * The maximum amount of change to the referenced Pokéathlon stat. */ @JsonProperty("max_change") val maxChange: Number, - /** * The nature causing the change. * @see Nature */ @JsonProperty("nature") val nature: NamedApiResource -) { - override fun toString(): String { - return "NaturePokeathlonStatAffect(maxChange=$maxChange, nature=$nature)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/NaturePokeathlonStatAffectSets.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NaturePokeathlonStatAffectSets.kt similarity index 66% rename from src/main/kotlin/entity/pokemon/NaturePokeathlonStatAffectSets.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NaturePokeathlonStatAffectSets.kt index 552eec9..99a84cd 100644 --- a/src/main/kotlin/entity/pokemon/NaturePokeathlonStatAffectSets.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NaturePokeathlonStatAffectSets.kt @@ -1,21 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -class NaturePokeathlonStatAffectSets( +data class NaturePokeathlonStatAffectSets( /** * A list of natures and how they change the referenced Pokéathlon stat. */ @JsonProperty("increase") val increase: List, - /** * A list of natures and how they change the referenced Pokéathlon stat. */ @JsonProperty("decrease") val decrease: List -) { - override fun toString(): String { - return "NaturePokeathlonStatAffectSets(increase=$increase, decrease=$decrease)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/NatureStatAffectSets.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NatureStatAffectSets.kt similarity index 63% rename from src/main/kotlin/entity/pokemon/NatureStatAffectSets.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NatureStatAffectSets.kt index ee00226..8cf5a43 100644 --- a/src/main/kotlin/entity/pokemon/NatureStatAffectSets.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NatureStatAffectSets.kt @@ -1,21 +1,15 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @property increase A list of natures and how they change the referenced stat. * @property decrease A list of natures and how they change the referenced stat. */ -class NatureStatAffectSets( - +data class NatureStatAffectSets( @JsonProperty("increase") val increase: List>, - @JsonProperty("decrease") val decrease: List> -) { - override fun toString(): String { - return "NatureStatAffectSets(increase=$increase, decrease=$decrease)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/NatureStatChange.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NatureStatChange.kt similarity index 61% rename from src/main/kotlin/entity/pokemon/NatureStatChange.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NatureStatChange.kt index 79ff55d..a651888 100644 --- a/src/main/kotlin/entity/pokemon/NatureStatChange.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/NatureStatChange.kt @@ -1,15 +1,14 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class NatureStatChange( +data class NatureStatChange( /** * The amount of change. */ @JsonProperty("max_change") val maxChange: Number, - /** * The stat being affected. * @see PokeathlonStat @@ -17,8 +16,4 @@ class NatureStatChange( */ @JsonProperty("pokeathlon_stat") val pokeathlonStat: NamedApiResource -) { - override fun toString(): String { - return "NatureStatChange(maxChange=$maxChange, pokeathlonStat=$pokeathlonStat)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PalParkEncounterArea.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PalParkEncounterArea.kt similarity index 70% rename from src/main/kotlin/entity/pokemon/PalParkEncounterArea.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PalParkEncounterArea.kt index d701ccc..93989e2 100644 --- a/src/main/kotlin/entity/pokemon/PalParkEncounterArea.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PalParkEncounterArea.kt @@ -1,24 +1,18 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @property baseScore The base score given to the player when the referenced Pokémon is caught during a pal park run. * @property rate The base rate for encountering the referenced Pokémon in this pal park area. * @property area The pal park area where this encounter happens. */ -class PalParkEncounterArea( +data class PalParkEncounterArea( @JsonProperty("base_score") val baseScore: Number, - @JsonProperty("rate") val rate: Number, - @JsonProperty("area") val area: NamedApiResource -) { - override fun toString(): String { - return "PalParkEncounterArea(baseScore=$baseScore, rate=$rate, area=$area)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokeathlonStat.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokeathlonStat.kt similarity index 72% rename from src/main/kotlin/entity/pokemon/PokeathlonStat.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokeathlonStat.kt index 2212339..dedddce 100644 --- a/src/main/kotlin/entity/pokemon/PokeathlonStat.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokeathlonStat.kt @@ -1,35 +1,28 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name - -class PokeathlonStat( +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +data class PokeathlonStat( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The name of this resource listed in different languages. */ @JsonProperty("names") val names: List, - /** * A detail of natures which affect this Pokéathlon stat positively or negatively. */ @JsonProperty("affecting_natures") val affectingNatures: NaturePokeathlonStatAffectSets -) { - override fun toString(): String { - return "PokeathlonStat(id=$id, name='$name', names=$names, affectingNatures=$affectingNatures)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/Pokemon.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Pokemon.kt similarity index 82% rename from src/main/kotlin/entity/pokemon/Pokemon.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Pokemon.kt index 89eb513..78a4e5d 100644 --- a/src/main/kotlin/entity/pokemon/Pokemon.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Pokemon.kt @@ -1,125 +1,102 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.common.VersionGameIndex +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VersionGameIndex -class Pokemon( +data class Pokemon( /** * The identifier for this resource. */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * The base experience gained for defeating this Pokémon. */ @JsonProperty("base_experience") val baseExperience: Number, - /** * The height of this Pokémon in decimetres. */ @JsonProperty("height") val height: Number, - /** * Set for exactly one Pokémon used as the default for each species. */ @JsonProperty("is_default") val isDefault: Boolean, - /** * Order for sorting. Almost national order, except families are grouped together. */ @JsonProperty("order") val order: Number, - /** * The weight of this Pokémon in hectograms. */ @JsonProperty("weight") val weight: Number, - /** * A list of abilities this Pokémon could potentially have. */ @JsonProperty("abilities") val abilities: List, - /** * A list of forms this Pokémon can take on. * @see PokemonForm */ @JsonProperty("forms") val forms: List>, - /** * A list of game indices relevent to Pokémon item by generation. */ @JsonProperty("game_indices") val gameIndices: List, - /** * A list of items this Pokémon may be holding when encountered. */ @JsonProperty("held_items") val heldItems: List, - /** * A link to a list of location areas, as well as encounter details pertaining to specific versions. */ @JsonProperty("location_area_encounters") val locationAreaEncounters: String, - /** * A list of moves along with learn methods and level details pertaining to specific version groups. */ @JsonProperty("moves") val moves: List, - /** * A list of details showing types this pokémon had in previous generations */ @JsonProperty("past_types") val pastTypes: List, - /** * A set of sprites used to depict this Pokémon in the game. A visual representation of the various sprites can be found at PokeAPI/sprites */ @JsonProperty("sprites") val sprites: PokemonSprites, - /** * The species this Pokémon belongs to. * @see PokemonSpecies */ @JsonProperty("species") val species: NamedApiResource, - /** * A list of base stat values for this Pokémon. */ @JsonProperty("stats") val stats: List, - /** * A list of details showing types this Pokémon has. */ @JsonProperty("types") val types: List -) { - override fun toString(): String = """ - Pokemon(id=$id, name='$name', baseExperience=$baseExperience, height=$height, isDefault=$isDefault, order=$order, - weight=$weight, abilities=$abilities, forms=$forms, gameIndices=$gameIndices, heldItems=$heldItems, - locationAreaEncounters='$locationAreaEncounters', moves=$moves, pastTypes=$pastTypes, sprites=$sprites, - species=$species, stats=$stats, types=$types) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonAbility.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonAbility.kt similarity index 78% rename from src/main/kotlin/entity/pokemon/PokemonAbility.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonAbility.kt index 272c51a..2458e96 100644 --- a/src/main/kotlin/entity/pokemon/PokemonAbility.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonAbility.kt @@ -1,22 +1,20 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class PokemonAbility( +data class PokemonAbility( /** * * Whether or not this is a hidden ability. */ @JsonProperty("is_hidden") val isHidden: Boolean, - /** * The slot this ability occupies in this Pokémon species. */ @JsonProperty("slot") val slot: Int, - /** * The ability the Pokémon may have. * @see Ability diff --git a/src/main/kotlin/entity/pokemon/PokemonColor.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonColor.kt similarity index 70% rename from src/main/kotlin/entity/pokemon/PokemonColor.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonColor.kt index 69cb641..208886a 100644 --- a/src/main/kotlin/entity/pokemon/PokemonColor.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonColor.kt @@ -1,8 +1,9 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * A class representing the details of a Pokémon color. @@ -12,21 +13,13 @@ import entity.common.NamedApiResource * @property names The name of this resource listed in different languages. * @property pokemonSpecies A list of the Pokémon species that have this color. */ -class PokemonColor( - +data class PokemonColor( @JsonProperty("id") val id: Int, - @JsonProperty("name") val name: String, - @JsonProperty("names") val names: List, - @JsonProperty("pokemon_species") val pokemonSpecies: List> -) { - override fun toString(): String { - return "PokemonColor(id=$id, name='$name', names=$names, pokemonSpecies=$pokemonSpecies" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonEncounter.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonEncounter.kt similarity index 60% rename from src/main/kotlin/entity/pokemon/PokemonEncounter.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonEncounter.kt index a03fd04..7f19833 100644 --- a/src/main/kotlin/entity/pokemon/PokemonEncounter.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonEncounter.kt @@ -1,9 +1,9 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.common.VersionEncounterDetail -import entity.locations.LocationArea +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VersionEncounterDetail +import fr.tykok.pokeapi.entities.locations.LocationArea /** * A class representing the encounter details of a Pokémon. @@ -11,15 +11,9 @@ import entity.locations.LocationArea * @property locationArea The location area the referenced Pokémon can be encountered in. * @property versionDetails A list of versions and encounters with the referenced Pokémon that might happen. */ -class PokemonEncounter( - +data class PokemonEncounter( @JsonProperty("location_area") val locationArea: NamedApiResource, - @JsonProperty("version_details") val versionDetails: Array -) { - override fun toString(): String { - return "PokemonEncounter(locationArea=$locationArea, versionDetails=${versionDetails.contentToString()})" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonForm.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonForm.kt similarity index 80% rename from src/main/kotlin/entity/pokemon/PokemonForm.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonForm.kt index 05ae900..8c7d7cb 100644 --- a/src/main/kotlin/entity/pokemon/PokemonForm.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonForm.kt @@ -1,9 +1,10 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource -import entity.games.VersionGroup +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.VersionGroup /** * A class representing the details of a Pokémon form. @@ -23,52 +24,33 @@ import entity.games.VersionGroup * @property names The form specific full name of this Pokémon form, or empty if the form does not have a specific name. * @property formNames The form specific form name of this Pokémon form, or empty if the form does not have a specific name. */ -class PokemonForm( +data class PokemonForm( @JsonProperty("id") val id: Int, - @JsonProperty("name") val name: String, - @JsonProperty("order") val order: Int, - @JsonProperty("form_order") val formOrder: Int, - @JsonProperty("is_default") val isDefault: Boolean, - @JsonProperty("is_battle_only") val isBattleOnly: Boolean, - @JsonProperty("is_mega") val isMega: Boolean, - @JsonProperty("form_name") val formName: String, - @JsonProperty("pokemon") val pokemon: NamedApiResource, - @JsonProperty("types") val types: List, - @JsonProperty("sprites") val sprites: PokemonFormSprites, - @JsonProperty("version_group") val versionGroup: NamedApiResource, - @JsonProperty("names") val names: List, - @JsonProperty("form_names") val formNames: List - -) { - override fun toString(): String { - return "PokemonForm(id=$id, name='$name', order=$order, formOrder=$formOrder, isDefault=$isDefault, isBattleOnly=$isBattleOnly, isMega=$isMega, " + - "formName='$formName', pokemon=$pokemon, types=$types, sprites=$sprites, versionGroup=$versionGroup, names=$name, formNames=$formName" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonFormSprites.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonFormSprites.kt similarity index 59% rename from src/main/kotlin/entity/pokemon/PokemonFormSprites.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonFormSprites.kt index 047ffa3..403c789 100644 --- a/src/main/kotlin/entity/pokemon/PokemonFormSprites.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonFormSprites.kt @@ -1,40 +1,22 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty data class PokemonFormSprites( @JsonProperty("front_default") val frontDefault: String?, - @JsonProperty("front_shiny") val frontShiny: String?, - @JsonProperty("back_default") val backDefault: String?, - @JsonProperty("back_shiny") val backShiny: String?, - @JsonProperty("back_female") val backFemale: String?, - @JsonProperty("back_shiny_female") val backShinyFemale: String?, - @JsonProperty("front_female") val frontFemale: String?, - @JsonProperty("front_shiny_female") val frontShinyFemale: String? -) { - override fun toString(): String { - return "frontDefault=$frontDefault," + - "frontShiny=$frontShiny" + - "backDefault=$backDefault" + - "backShiny=$backShiny" + - "backFemale=$backFemale" + - "backShinyFemale=$backShinyFemale" + - "frontFemale=$frontFemale" + - "frontShinyFemale=$frontShinyFemale" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonFormType.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonFormType.kt similarity index 63% rename from src/main/kotlin/entity/pokemon/PokemonFormType.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonFormType.kt index 75b9d35..c712fc0 100644 --- a/src/main/kotlin/entity/pokemon/PokemonFormType.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonFormType.kt @@ -1,23 +1,18 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class PokemonFormType( +data class PokemonFormType( /** * The order the Pokémon's types are listed in. */ @JsonProperty("slot") val slot: Number, - /** * The type the referenced Form has. * @see Type */ @JsonProperty("type") val type: NamedApiResource -) { - override fun toString(): String { - return "slot=$slot, type=$type" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonHabitat.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHabitat.kt similarity index 53% rename from src/main/kotlin/entity/pokemon/PokemonHabitat.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHabitat.kt index fbcd0ec..383598a 100644 --- a/src/main/kotlin/entity/pokemon/PokemonHabitat.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHabitat.kt @@ -1,24 +1,17 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource - -class PokemonHabitat( +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +data class PokemonHabitat( @JsonProperty("id") val id: Number, - @JsonProperty("name") val name: String, - @JsonProperty("names") val names: List, - @JsonProperty("pokemon_species") val pokemonSpecies: List> -) { - override fun toString(): String { - return "PokemonHabitat(id=$id, name='$name', names=$names, pokemonSpecies=$pokemonSpecies)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonHeldItem.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHeldItem.kt similarity index 59% rename from src/main/kotlin/entity/pokemon/PokemonHeldItem.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHeldItem.kt index 9932cae..4daff9a 100644 --- a/src/main/kotlin/entity/pokemon/PokemonHeldItem.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHeldItem.kt @@ -1,14 +1,13 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon -import entity.common.NamedApiResource -import entity.items.Item +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.items.Item -class PokemonHeldItem( +data class PokemonHeldItem( /** * The item the referenced Pokémon holds. */ val item: NamedApiResource, - /** * The details for the version that this item is held in by the Pokémon. */ diff --git a/src/main/kotlin/entity/pokemon/PokemonHeldItemVersion.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHeldItemVersion.kt similarity index 50% rename from src/main/kotlin/entity/pokemon/PokemonHeldItemVersion.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHeldItemVersion.kt index 95cb7e9..b195db5 100644 --- a/src/main/kotlin/entity/pokemon/PokemonHeldItemVersion.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonHeldItemVersion.kt @@ -1,14 +1,13 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon -import entity.common.NamedApiResource -import entity.games.Version +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Version -class PokemonHeldItemVersion( +data class PokemonHeldItemVersion( /** * The version in which the item is held. */ val version: NamedApiResource, - /** * How often the item is held. */ diff --git a/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonLocationArea.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonLocationArea.kt new file mode 100644 index 0000000..e27dcc6 --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonLocationArea.kt @@ -0,0 +1,14 @@ +package fr.tykok.pokeapi.entities.pokemon + +import com.fasterxml.jackson.annotation.JsonProperty +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.VersionEncounterDetail +import fr.tykok.pokeapi.entities.locations.LocationArea + +data class PokemonLocationArea( + @JsonProperty("location_area") + val locationArea: NamedApiResource, + @JsonProperty("version_details") + val versionDetails: List +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonMove.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonMove.kt similarity index 63% rename from src/main/kotlin/entity/pokemon/PokemonMove.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonMove.kt index 83e3d69..39dc0c2 100644 --- a/src/main/kotlin/entity/pokemon/PokemonMove.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonMove.kt @@ -1,17 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.moves.Move +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.moves.Move -class PokemonMove( +data class PokemonMove( /** * The move the Pokémon can learn. * @see Move */ @JsonProperty("move") val move: NamedApiResource, - @JsonProperty("version_group_details") val versionGroupDetails: Array ) diff --git a/src/main/kotlin/entity/pokemon/PokemonMoveVersion.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonMoveVersion.kt similarity index 71% rename from src/main/kotlin/entity/pokemon/PokemonMoveVersion.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonMoveVersion.kt index 7eab64f..86f6e67 100644 --- a/src/main/kotlin/entity/pokemon/PokemonMoveVersion.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonMoveVersion.kt @@ -1,23 +1,21 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.games.VersionGroup -import entity.moves.MoveLearnMethod +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.moves.MoveLearnMethod -class PokemonMoveVersion( +data class PokemonMoveVersion( /** * The method by which the move is learned. * @see MoveLearnMethod */ @JsonProperty("move_learn_method") val moveLearnMethod: NamedApiResource, - /** * The version group in which the move is learned. * @see VersionGroup */ @JsonProperty("version_group") val versionGroup: NamedApiResource, - /** * The minimum level to learn the move. Specified for each different move learn method. */ diff --git a/src/main/kotlin/entity/pokemon/PokemonShape.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonShape.kt similarity index 75% rename from src/main/kotlin/entity/pokemon/PokemonShape.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonShape.kt index 43dd1ad..c8de86a 100644 --- a/src/main/kotlin/entity/pokemon/PokemonShape.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonShape.kt @@ -1,8 +1,9 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * Represents a shape that a Pokémon species can take on. @@ -14,23 +15,14 @@ import entity.common.NamedApiResource * @property pokemonSpecies A list of the Pokémon species that have this shape. */ data class PokemonShape( - @JsonProperty("id") val id: Number, - @JsonProperty("name") val name: String, - @JsonProperty("awesome_names") val awesomeNames: List, - @JsonProperty("names") val names: List, - @JsonProperty("pokemon_species") val pokemonSpecies: List> -) { - override fun toString(): String { - return "PokemonShape(id=$id, name='$name', awesomeNames=$awesomeNames, names=$names, pokemonSpecies=$pokemonSpecies)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonSpecies.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpecies.kt similarity index 65% rename from src/main/kotlin/entity/pokemon/PokemonSpecies.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpecies.kt index f3eb3cd..9b9fbdb 100644 --- a/src/main/kotlin/entity/pokemon/PokemonSpecies.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpecies.kt @@ -1,105 +1,70 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.APIResource -import entity.common.Description -import entity.common.FlavorText -import entity.common.Name -import entity.common.NamedApiResource -import entity.games.Generation +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.APIResource +import fr.tykok.pokeapi.entities.common.Description +import fr.tykok.pokeapi.entities.common.FlavorText +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Generation /** * Represents a Pokémon species. */ -class PokemonSpecies( - +data class PokemonSpecies( @JsonProperty("id") val id: Number, - @JsonProperty("name") val name: String, - @JsonProperty("order") val order: Number, - @JsonProperty("gender_rate") val genderRate: Number, - @JsonProperty("capture_rate") val captureRate: Number, - @JsonProperty("base_happiness") val baseHappiness: Number, - @JsonProperty("is_baby") val isBaby: Boolean, - @JsonProperty("is_legendary") val isLegendary: Boolean, - @JsonProperty("is_mythical") val isMythical: Boolean, - @JsonProperty("hatch_counter") val hatchCounter: Number, - @JsonProperty("has_gender_differences") val hasGenderDifferences: Boolean, - @JsonProperty("forms_switchable") val formsSwitchable: Boolean, - @JsonProperty("growth_rate") val growthRate: NamedApiResource, - @JsonProperty("pokedex_numbers") val pokedexNumbers: List, - @JsonProperty("egg_groups") val eggGroups: List>, - @JsonProperty("color") val color: NamedApiResource, - @JsonProperty("shape") val shape: NamedApiResource, - @JsonProperty("evolves_from_species") val evolvesFromSpecies: NamedApiResource?, - @JsonProperty("evolution_chain") val evolutionChain: APIResource, - @JsonProperty("habitat") val habitat: NamedApiResource?, - @JsonProperty("generation") val generation: NamedApiResource, - @JsonProperty("names") val names: List, - @JsonProperty("pal_park_encounters") val palParkEncounters: List, - @JsonProperty("flavor_text_entries") val flavorTextEntries: List, - @JsonProperty("form_descriptions") val formDescriptions: List, - @JsonProperty("genera") val genera: List, - @JsonProperty("varieties") val varieties: List -) { - override fun toString() = - """PokemonSpecies(id=$id, name='$name', order=$order, genderRate=$genderRate, captureRate=$captureRate, baseHappiness=$baseHappiness, - isBaby=$isBaby, isLegendary=$isLegendary, isMythical=$isMythical, hatchCounter=$hatchCounter, hasGenderDifferences=$hasGenderDifferences, - formsSwitchable=$formsSwitchable, growthRate=$growthRate, pokedexNumbers=$pokedexNumbers, eggGroups=$eggGroups, color=$color, - shape=$shape, evolvesFromSpecies=$evolvesFromSpecies, evolutionChain=$evolutionChain, habitat=$habitat, generation=$generation, - names=$names, palParkEncounters=$palParkEncounters, flavorTextEntries=$flavorTextEntries, formDescriptions=$formDescriptions, - genera=$genera, varieties=$varieties) - """ -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/PokemonSpeciesDexEntry.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesDexEntry.kt similarity index 57% rename from src/main/kotlin/entity/pokemon/PokemonSpeciesDexEntry.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesDexEntry.kt index 4f53c79..6664f26 100644 --- a/src/main/kotlin/entity/pokemon/PokemonSpeciesDexEntry.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesDexEntry.kt @@ -1,21 +1,16 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource -import entity.games.Pokedex +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Pokedex /** * @property entryNumber The index number within the Pokédex. * @property pokedex The Pokédex the referenced Pokémon species can be found in. */ -class PokemonSpeciesDexEntry( +data class PokemonSpeciesDexEntry( @JsonProperty("entry_number") val entryNumber: Number, - @JsonProperty("pokedex") val pokedex: NamedApiResource -) { - override fun toString(): String { - return "PokemonSpeciesDexEntry(entryNumber=$entryNumber, pokedex=$pokedex)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonSpeciesGender.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesGender.kt similarity index 67% rename from src/main/kotlin/entity/pokemon/PokemonSpeciesGender.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesGender.kt index abdca07..11662e3 100644 --- a/src/main/kotlin/entity/pokemon/PokemonSpeciesGender.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesGender.kt @@ -1,15 +1,14 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class PokemonSpeciesGender( +data class PokemonSpeciesGender( /** * The chance of this Pokémon being female, in eighths; or -1 for genderless. */ @JsonProperty("rate") val rate: Number, - /** * A Pokémon species that can be the referenced gender. * @see PokemonSpecies @@ -17,8 +16,4 @@ class PokemonSpeciesGender( */ @JsonProperty("pokemon_species") val pokemonSpecies: NamedApiResource -) { - override fun toString(): String { - return "rate = $rate pokemonSpecies = $pokemonSpecies" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonSpeciesVariety.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesVariety.kt similarity index 58% rename from src/main/kotlin/entity/pokemon/PokemonSpeciesVariety.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesVariety.kt index f84e4b6..bd9db87 100644 --- a/src/main/kotlin/entity/pokemon/PokemonSpeciesVariety.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSpeciesVariety.kt @@ -1,20 +1,15 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource /** * @property isDefault Whether this variety is the default variety. * @property pokemon The Pokémon variety. */ -class PokemonSpeciesVariety( +data class PokemonSpeciesVariety( @JsonProperty("is_default") val isDefault: Boolean, - @JsonProperty("pokemon") val pokemon: NamedApiResource -) { - override fun toString(): String { - return "PokemonSpeciesVariety(isDefault=$isDefault, pokemon=$pokemon)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonSprites.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSprites.kt similarity index 72% rename from src/main/kotlin/entity/pokemon/PokemonSprites.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSprites.kt index 00b1a81..e43ceb0 100644 --- a/src/main/kotlin/entity/pokemon/PokemonSprites.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonSprites.kt @@ -1,4 +1,4 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty @@ -14,66 +14,39 @@ import com.fasterxml.jackson.annotation.JsonProperty * @property backFemale The female depiction of this Pokémon from the back in battle. * @property backShinyFemale The shiny female depiction of this Pokémon from the back in battle. */ -class PokemonSprites( +data class PokemonSprites( @JsonProperty("front_default") val frontDefault: String?, - @JsonProperty("front_shiny") val frontShiny: String?, - @JsonProperty("front_female") val frontFemale: String?, - @JsonProperty("front_shiny_female") val frontShinyFemale: String?, - @JsonProperty("back_default") val backDefault: String?, - @JsonProperty("back_shiny") val backShiny: String?, - @JsonProperty("back_female") val backFemale: String?, - @JsonProperty("back_shiny_female") val backShinyFemale: String?, - @JsonProperty("back_gray") val backGray: String?, - @JsonProperty("front_gray") val frontGray: String?, - @JsonProperty("back_transparent") val backTransparent: String?, - @JsonProperty("front_transparent") val frontTransparent: String?, - @JsonProperty("back_shiny_transparent") val backShinyTransparent: String?, - @JsonProperty("front_shiny_transparent") val frontShinyTransparent: String?, - @JsonProperty("animated") val animated: PokemonSprites?, - @JsonProperty("versions") val versions: Map>?, - @JsonProperty("other") val other: Map? -) { - // constructor() : this(null, null, null, null, null, null, null, null, null, null) - - override fun toString(): String { - return "PokemonSprites(frontDefault=$frontDefault, frontShiny=$frontShiny, frontFemale=$frontFemale, " + - "frontShinyFemale=$frontShinyFemale, backDefault=$backDefault, backShiny=$backShiny, " + - "backFemale=$backFemale, backShinyFemale=$backShinyFemale, backGray=$backGray, " + - "frontGray=$frontGray, backTransparent=$backTransparent, frontTransparent=$frontTransparent, " + - "backShinyTransparent=$backShinyTransparent, frontShinyTransparent=$frontShinyTransparent, " + - "versions=$versions, other=$other)" - } -} +) diff --git a/src/main/kotlin/entity/pokemon/PokemonStat.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonStat.kt similarity index 77% rename from src/main/kotlin/entity/pokemon/PokemonStat.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonStat.kt index 06b2b03..0a32d44 100644 --- a/src/main/kotlin/entity/pokemon/PokemonStat.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonStat.kt @@ -1,22 +1,20 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class PokemonStat( +data class PokemonStat( /** * The stat the Pokémon has. * @see Stat */ @JsonProperty("stat") val stat: NamedApiResource, - /** * The effort points (EV) the Pokémon has in the stat. */ @JsonProperty("effort") val effort: Number, - /** * The base value of the stat. */ diff --git a/src/main/kotlin/entity/pokemon/PokemonType.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonType.kt similarity index 71% rename from src/main/kotlin/entity/pokemon/PokemonType.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonType.kt index ffb8d84..3cc21a7 100644 --- a/src/main/kotlin/entity/pokemon/PokemonType.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonType.kt @@ -1,15 +1,14 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class PokemonType( +data class PokemonType( /** * The order the Pokémon's types are listed in. */ @JsonProperty("slot") val slot: Number, - /** * The type the referenced Pokémon has. * @see Type diff --git a/src/main/kotlin/entity/pokemon/PokemonTypePast.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonTypePast.kt similarity index 62% rename from src/main/kotlin/entity/pokemon/PokemonTypePast.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonTypePast.kt index 8a81fb4..d93352f 100644 --- a/src/main/kotlin/entity/pokemon/PokemonTypePast.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/PokemonTypePast.kt @@ -1,15 +1,14 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon -import entity.common.NamedApiResource -import entity.games.Generation +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Generation -class PokemonTypePast( +data class PokemonTypePast( /** * The last generation in which the referenced pokémon had the listed types. * @see Generation */ val generation: NamedApiResource, - /** * The types the referenced pokémon had in the listed generation. */ diff --git a/src/main/kotlin/entity/pokemon/Stat.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Stat.kt similarity index 76% rename from src/main/kotlin/entity/pokemon/Stat.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Stat.kt index b215002..79860f7 100644 --- a/src/main/kotlin/entity/pokemon/Stat.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Stat.kt @@ -1,10 +1,11 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.APIResource -import entity.common.Name -import entity.common.NamedApiResource -import entity.moves.MoveDamageClass +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.APIResource +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.moves.MoveDamageClass /** * A stat refers to an aspect of a Pokémon that is used to represent its strengths and weaknesses. Each Pokémon has @@ -21,37 +22,22 @@ import entity.moves.MoveDamageClass * @property names The name of this resource listed in different languages. */ data class Stat( - @JsonProperty("id") val id: Int, - @JsonProperty("name") val name: String, - @JsonProperty("game_index") val gameIndex: String, - @JsonProperty("is_battle_only") val isBattleOnly: Boolean, - @JsonProperty("affecting_moves") val affectingMoves: MoveStatAffectSets, - @JsonProperty("affecting_natures") val affectingNatures: NatureStatAffectSets, - @JsonProperty("characteristics") val characteristics: List, - @JsonProperty("move_damage_class") val moveDamageClass: NamedApiResource?, - @JsonProperty("names") val names: List -) { - override fun toString(): String { - return "Stat(id=$id, name='$name', gameIndex='$gameIndex', isBattleOnly=$isBattleOnly, affectingMoves=$affectingMoves, " + - "affectingNatures=$affectingNatures, characteristics=$characteristics, moveDamageClass=$moveDamageClass, " + - "names=$names" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/entity/pokemon/Type.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Type.kt similarity index 59% rename from src/main/kotlin/entity/pokemon/Type.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Type.kt index 311ba64..540b5fa 100644 --- a/src/main/kotlin/entity/pokemon/Type.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/Type.kt @@ -1,46 +1,33 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.GenerationGameIndex -import entity.common.Name -import entity.common.NamedApiResource -import entity.games.Generation -import entity.moves.Move -import entity.moves.MoveDamageClass +import fr.tykok.pokeapi.entities.PokeApiObject +import fr.tykok.pokeapi.entities.common.GenerationGameIndex +import fr.tykok.pokeapi.entities.common.Name +import fr.tykok.pokeapi.entities.common.NamedApiResource +import fr.tykok.pokeapi.entities.games.Generation +import fr.tykok.pokeapi.entities.moves.Move +import fr.tykok.pokeapi.entities.moves.MoveDamageClass data class Type( @JsonProperty("id") val id: Int, - @JsonProperty("name") val name: String, - @JsonProperty("damage_relations") val damageRelations: TypeRelations, - @JsonProperty("past_damage_relations") val pastDamageRelations: List, - @JsonProperty("game_indices") val gameIndices: List, - @JsonProperty("generation") val generation: NamedApiResource, - @JsonProperty("move_damage_class") val moveDamageClass: NamedApiResource, - @JsonProperty("names") val names: List, - @JsonProperty("pokemon") val pokemon: List, - @JsonProperty("moves") val moves: List> -) { - override fun toString(): String { - return "Type(id=$id, name='$name', damageRelations=$damageRelations, pastDamageRelations=$pastDamageRelations, gameIndices=$gameIndices, " + - "generation=$generation, moveDamageClass=$moveDamageClass, names=$names, pokemon=$pokemon, moves=$moves)" - } -} +) : PokeApiObject diff --git a/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypePokemon.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypePokemon.kt new file mode 100644 index 0000000..c5a2f74 --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypePokemon.kt @@ -0,0 +1,11 @@ +package fr.tykok.pokeapi.entities.pokemon + +import com.fasterxml.jackson.annotation.JsonProperty +import fr.tykok.pokeapi.entities.common.NamedApiResource + +data class TypePokemon( + @JsonProperty("slot") + val slot: Number, + @JsonProperty("pokemon") + val pokemon: NamedApiResource +) diff --git a/src/main/kotlin/entity/pokemon/TypeRelations.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypeRelations.kt similarity index 82% rename from src/main/kotlin/entity/pokemon/TypeRelations.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypeRelations.kt index 9570409..0a97bae 100644 --- a/src/main/kotlin/entity/pokemon/TypeRelations.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypeRelations.kt @@ -1,9 +1,9 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource +import fr.tykok.pokeapi.entities.common.NamedApiResource -class TypeRelations( +data class TypeRelations( @JsonProperty("no_damage_to") val noDamageTo: Array>, @JsonProperty("half_damage_to") val halfDamageTo: Array>, @JsonProperty("double_damage_to") val doubleDamageTo: Array>, diff --git a/src/main/kotlin/entity/pokemon/TypeRelationsPast.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypeRelationsPast.kt similarity index 62% rename from src/main/kotlin/entity/pokemon/TypeRelationsPast.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypeRelationsPast.kt index 83d81bd..75d67a8 100644 --- a/src/main/kotlin/entity/pokemon/TypeRelationsPast.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/pokemon/TypeRelationsPast.kt @@ -1,10 +1,9 @@ -package entity.pokemon +package fr.tykok.pokeapi.entities.pokemon import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.NamedApiResource - -class TypeRelationsPast( +import fr.tykok.pokeapi.entities.common.NamedApiResource +data class TypeRelationsPast( /** * A list of details of how effective this type was toward others and vice versa in previous generations * @see NamedApiResource @@ -12,11 +11,6 @@ class TypeRelationsPast( */ @JsonProperty("no_damage_to") val generation: NamedApiResource, - @JsonProperty("damage_relations") val damageRelations: TypeRelations -) { - override fun toString(): String { - return "TypeRelationsPast(generation=$generation, damageRelations=$damageRelations)" - } -} +) diff --git a/src/main/kotlin/entity/utility/Language.kt b/src/main/kotlin/fr/tykok/pokeapi/entities/utility/Language.kt similarity index 80% rename from src/main/kotlin/entity/utility/Language.kt rename to src/main/kotlin/fr/tykok/pokeapi/entities/utility/Language.kt index 806eaea..ae8d0d5 100644 --- a/src/main/kotlin/entity/utility/Language.kt +++ b/src/main/kotlin/fr/tykok/pokeapi/entities/utility/Language.kt @@ -1,7 +1,7 @@ -package entity.utility +package fr.tykok.pokeapi.entities.utility import com.fasterxml.jackson.annotation.JsonProperty -import entity.common.Name +import fr.tykok.pokeapi.entities.common.Name /** * Languages for translations of API resource information. @@ -10,47 +10,36 @@ import entity.common.Name * @version 1.0.0 * @since 2022-07-27 */ -class Language( - +data class Language( /** * The identifier for this resource */ @JsonProperty("id") val id: Number, - /** * The name for this resource. */ @JsonProperty("name") val name: String, - /** * Whether the games are published in this language. */ @JsonProperty("official") val official: Boolean, - /** * The two-letter code of the country where this language is spoken. Note that it is not unique. */ @JsonProperty("iso639") val iso639: String, - /** * The two-letter code of the language. Note that it is not unique. */ @JsonProperty("iso3166") val iso3166: String, - /** * The name of this resource listed in different languages. * @see Name */ @JsonProperty("names") val names: Array - -) { - override fun toString() = - "Language(id=$id, name=$name, official=$official, iso639=$iso639, iso3166=$iso3166, " + - "names=${names.contentToString()})" -} +) diff --git a/src/main/kotlin/fr/tykok/pokeapi/exception/PokeApiException.kt b/src/main/kotlin/fr/tykok/pokeapi/exception/PokeApiException.kt new file mode 100644 index 0000000..dcb0fd9 --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/exception/PokeApiException.kt @@ -0,0 +1,7 @@ +package fr.tykok.pokeapi.exception + +import java.lang.Exception + +abstract class PokeApiException( + message: String +) : Exception(message) diff --git a/src/main/kotlin/fr/tykok/pokeapi/exception/UnknownEndpointException.kt b/src/main/kotlin/fr/tykok/pokeapi/exception/UnknownEndpointException.kt new file mode 100644 index 0000000..d842478 --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/exception/UnknownEndpointException.kt @@ -0,0 +1,7 @@ +package fr.tykok.pokeapi.exception + +import fr.tykok.pokeapi.PokeApi + +class UnknownEndpointException( + className: String +) : PokeApiException("Unknown endpoint: ${PokeApi.BASE_URL}/$className") diff --git a/src/main/kotlin/fr/tykok/pokeapi/http/EndpointReference.kt b/src/main/kotlin/fr/tykok/pokeapi/http/EndpointReference.kt new file mode 100644 index 0000000..b7e7b40 --- /dev/null +++ b/src/main/kotlin/fr/tykok/pokeapi/http/EndpointReference.kt @@ -0,0 +1,148 @@ +package fr.tykok.pokeapi.http + +import fr.tykok.pokeapi.entities.berries.Berry +import fr.tykok.pokeapi.entities.berries.BerryFirmness +import fr.tykok.pokeapi.entities.berries.BerryFlavor +import fr.tykok.pokeapi.entities.contests.ContestEffect +import fr.tykok.pokeapi.entities.contests.ContestType +import fr.tykok.pokeapi.entities.contests.SuperContestEffects +import fr.tykok.pokeapi.entities.encounters.EncounterCondition +import fr.tykok.pokeapi.entities.encounters.EncounterConditionValue +import fr.tykok.pokeapi.entities.encounters.EncounterMethod +import fr.tykok.pokeapi.entities.evolution.EvolutionChain +import fr.tykok.pokeapi.entities.evolution.EvolutionTrigger +import fr.tykok.pokeapi.entities.games.Generation +import fr.tykok.pokeapi.entities.games.Pokedex +import fr.tykok.pokeapi.entities.games.Version +import fr.tykok.pokeapi.entities.games.VersionGroup +import fr.tykok.pokeapi.entities.items.Item +import fr.tykok.pokeapi.entities.items.ItemAttribute +import fr.tykok.pokeapi.entities.items.ItemCategory +import fr.tykok.pokeapi.entities.items.ItemFlingEffect +import fr.tykok.pokeapi.entities.items.ItemPocket +import fr.tykok.pokeapi.entities.locations.Location +import fr.tykok.pokeapi.entities.locations.LocationArea +import fr.tykok.pokeapi.entities.locations.PalParkArea +import fr.tykok.pokeapi.entities.locations.Region +import fr.tykok.pokeapi.entities.machines.Machine +import fr.tykok.pokeapi.entities.moves.Move +import fr.tykok.pokeapi.entities.moves.MoveAilment +import fr.tykok.pokeapi.entities.moves.MoveBattleStyle +import fr.tykok.pokeapi.entities.moves.MoveCategory +import fr.tykok.pokeapi.entities.moves.MoveDamageClass +import fr.tykok.pokeapi.entities.moves.MoveLearnMethod +import fr.tykok.pokeapi.entities.moves.MoveTarget +import fr.tykok.pokeapi.entities.pokemon.Ability +import fr.tykok.pokeapi.entities.pokemon.Characteristic +import fr.tykok.pokeapi.entities.pokemon.EggGroup +import fr.tykok.pokeapi.entities.pokemon.Gender +import fr.tykok.pokeapi.entities.pokemon.GrowthRate +import fr.tykok.pokeapi.entities.pokemon.Nature +import fr.tykok.pokeapi.entities.pokemon.PokeathlonStat +import fr.tykok.pokeapi.entities.pokemon.Pokemon +import fr.tykok.pokeapi.entities.pokemon.PokemonColor +import fr.tykok.pokeapi.entities.pokemon.PokemonForm +import fr.tykok.pokeapi.entities.pokemon.PokemonHabitat +import fr.tykok.pokeapi.entities.pokemon.PokemonLocationArea +import fr.tykok.pokeapi.entities.pokemon.PokemonShape +import fr.tykok.pokeapi.entities.pokemon.PokemonSpecies +import fr.tykok.pokeapi.entities.pokemon.Stat +import fr.tykok.pokeapi.entities.pokemon.Type +import fr.tykok.pokeapi.exception.UnknownEndpointException + +inline fun getEndpoint(): String { + val elementType = + when (T::class) { + /** + * Berries + */ + Berry::class -> "berry" + BerryFirmness::class -> "berry-firmness" + BerryFlavor::class -> "berry-flavor" + + /** + * Contests + */ + ContestType::class -> "contest-type" + ContestEffect::class -> "contest-effect" + SuperContestEffects::class -> "super-contest-effect" + + /** + * Encounter + */ + EncounterMethod::class -> "encounter-method" + EncounterCondition::class -> "encounter-condition" + EncounterConditionValue::class -> "encounter-condition-value" + + /** + * Evolution + */ + EvolutionChain::class -> "evolution-chain" + EvolutionTrigger::class -> "evolution-trigger" + + /** + * Games + */ + Generation::class -> "generation" + Pokedex::class -> "pokedex" + Version::class -> "version" + VersionGroup::class -> "version-group" + + /** + * Item + */ + Item::class -> "item" + ItemAttribute::class -> "item-attribute" + ItemCategory::class -> "item-category" + ItemFlingEffect::class -> "item-fling-effect" + ItemPocket::class -> "item-pocket" + + /** + *Locations + */ + Location::class -> "location" + LocationArea::class -> "location-area" + PalParkArea::class -> "pal-park-area" + Region::class -> "region" + + /** + * Machine + */ + Machine::class -> "machine" + + /** + * Moves + */ + Move::class -> "move" + MoveAilment::class -> "move-ailment" + MoveBattleStyle::class -> "move-battle-style" + MoveCategory::class -> "move-category" + MoveDamageClass::class -> "move-damage-class" + MoveLearnMethod::class -> "move-learn-method" + MoveTarget::class -> "move-target" + + /** + * Pokemon + */ + Pokemon::class -> "pokemon" + Ability::class -> "ability" + Characteristic::class -> "characteristic" + EggGroup::class -> "egg-group" + Gender::class -> "gender" + GrowthRate::class -> "growth-rate" + Nature::class -> "nature" + PokeathlonStat::class -> "pokeathlon-stat" + PokemonLocationArea::class -> "pokemon-location-area" + PokemonColor::class -> "pokemon-color" + PokemonForm::class -> "pokemon-form" + PokemonHabitat::class -> "pokemon-habitat" + PokemonShape::class -> "pokemon-shape" + PokemonSpecies::class -> "pokemon-species" + Stat::class -> "stat" + Type::class -> "type" + + else -> throw UnknownEndpointException(className = T::class.simpleName!!) + } + + return elementType +} diff --git a/src/main/kotlin/http/EndpointReference.kt b/src/main/kotlin/http/EndpointReference.kt deleted file mode 100644 index bb69afd..0000000 --- a/src/main/kotlin/http/EndpointReference.kt +++ /dev/null @@ -1,147 +0,0 @@ -package http - -import entity.berries.Berry -import entity.berries.BerryFirmness -import entity.berries.BerryFlavor -import entity.contests.ContestEffect -import entity.contests.ContestType -import entity.contests.SuperContestEffects -import entity.encounters.EncounterCondition -import entity.encounters.EncounterConditionValue -import entity.encounters.EncounterMethod -import entity.evolution.EvolutionChain -import entity.evolution.EvolutionTrigger -import entity.games.Generation -import entity.games.Pokedex -import entity.games.Version -import entity.games.VersionGroup -import entity.items.Item -import entity.items.ItemAttribute -import entity.items.ItemCategory -import entity.items.ItemFlingEffect -import entity.items.ItemPocket -import entity.locations.Location -import entity.locations.LocationArea -import entity.locations.PalParkArea -import entity.locations.Region -import entity.machines.Machine -import entity.moves.Move -import entity.moves.MoveAilment -import entity.moves.MoveBattleStyle -import entity.moves.MoveCategory -import entity.moves.MoveDamageClass -import entity.moves.MoveLearnMethod -import entity.moves.MoveTarget -import entity.pokemon.Ability -import entity.pokemon.Characteristic -import entity.pokemon.EggGroup -import entity.pokemon.Gender -import entity.pokemon.GrowthRate -import entity.pokemon.Nature -import entity.pokemon.PokeathlonStat -import entity.pokemon.Pokemon -import entity.pokemon.PokemonColor -import entity.pokemon.PokemonForm -import entity.pokemon.PokemonHabitat -import entity.pokemon.PokemonLocationArea -import entity.pokemon.PokemonShape -import entity.pokemon.PokemonSpecies -import entity.pokemon.Stat -import entity.pokemon.Type -import exception.UnknownEndpointException - -inline fun getEndpoint(): String { - val elementType = when (T::class) { - /** - * Berries - */ - Berry::class -> "berry" - BerryFirmness::class -> "berry-firmness" - BerryFlavor::class -> "berry-flavor" - - /** - * Contests - */ - ContestType::class -> "contest-type" - ContestEffect::class -> "contest-effect" - SuperContestEffects::class -> "super-contest-effect" - - /** - * Encounter - */ - EncounterMethod::class -> "encounter-method" - EncounterCondition::class -> "encounter-condition" - EncounterConditionValue::class -> "encounter-condition-value" - - /** - * Evolution - */ - EvolutionChain::class -> "evolution-chain" - EvolutionTrigger::class -> "evolution-trigger" - - /** - * Games - */ - Generation::class -> "generation" - Pokedex::class -> "pokedex" - Version::class -> "version" - VersionGroup::class -> "version-group" - - /** - * Item - */ - Item::class -> "item" - ItemAttribute::class -> "item-attribute" - ItemCategory::class -> "item-category" - ItemFlingEffect::class -> "item-fling-effect" - ItemPocket::class -> "item-pocket" - - /** - *Locations - */ - Location::class -> "location" - LocationArea::class -> "location-area" - PalParkArea::class -> "pal-park-area" - Region::class -> "region" - - /** - * Machine - */ - Machine::class -> "machine" - - /** - * Moves - */ - Move::class -> "move" - MoveAilment::class -> "move-ailment" - MoveBattleStyle::class -> "move-battle-style" - MoveCategory::class -> "move-category" - MoveDamageClass::class -> "move-damage-class" - MoveLearnMethod::class -> "move-learn-method" - MoveTarget::class -> "move-target" - - /** - * Pokemon - */ - Pokemon::class -> "pokemon" - Ability::class -> "ability" - Characteristic::class -> "characteristic" - EggGroup::class -> "egg-group" - Gender::class -> "gender" - GrowthRate::class -> "growth-rate" - Nature::class -> "nature" - PokeathlonStat::class -> "pokeathlon-stat" - PokemonLocationArea::class -> "pokemon-location-area" - PokemonColor::class -> "pokemon-color" - PokemonForm::class -> "pokemon-form" - PokemonHabitat::class -> "pokemon-habitat" - PokemonShape::class -> "pokemon-shape" - PokemonSpecies::class -> "pokemon-species" - Stat::class -> "stat" - Type::class -> "type" - - else -> throw UnknownEndpointException(className = T::class.simpleName!!) - } - - return elementType -} diff --git a/src/test/kotlin/PokeApiTest.kt b/src/test/kotlin/PokeApiTest.kt deleted file mode 100644 index 87ecf94..0000000 --- a/src/test/kotlin/PokeApiTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -import entity.common.NamedApiResources -import entity.pokemon.Pokemon -import exception.HttpBodyResponseException -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows - -class PokeApiTest { - - @Test - fun `When try to get a Pokemon by existing id, should return the Pokemon`() { - val actual = PokeApi.get(id = 1) - assertEquals("bulbasaur", actual.name) - assertTrue(actual.javaClass == Pokemon::class.java) - } - - @Test - fun `When try to get a Pokemon by existing name, should return the Pokemon`() { - val actual = PokeApi.get(name = "bulbasaur") - assertTrue(actual.javaClass == Pokemon::class.java) - } - - @Test - fun `When try to get a Pokemon by non-existing name, should throw an exception`() { - assertThrows { PokeApi.get(name = "MissingNo") } - } - - @Test - fun `When try to get a Pokemon by non-existing id, should throw an exception`() { - assertThrows { PokeApi.get(id = -1) } - } - - @Test - fun `When try to get a list of Pokemon, should return a list of Pokemon`() { - val actual = PokeApi.get(limit = 10, offset = 0) - assertEquals(10, actual.results.size) - assertTrue(actual.javaClass == NamedApiResources::class.java) - } -} diff --git a/src/test/kotlin/fr/tykok/pokeapi/BerryTest.kt b/src/test/kotlin/fr/tykok/pokeapi/BerryTest.kt new file mode 100644 index 0000000..af872ed --- /dev/null +++ b/src/test/kotlin/fr/tykok/pokeapi/BerryTest.kt @@ -0,0 +1,60 @@ +import fr.tykok.pokeapi.PokeApi +import fr.tykok.pokeapi.entities.berries.Berry +import io.mockk.every +import io.mockk.mockk +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.Response +import okhttp3.ResponseBody.Companion.toResponseBody +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertInstanceOf +import org.junit.jupiter.api.Test + +class BerryTest { + + @Test + fun `When try to get a berry with an existing id, then should return a berry `() { + // Given + val id = 1 + val responseMock = mockk() + every { OkHttpClient().newCall(any()).execute() } returns responseMock + every { responseMock.body } returns ("{\n" + + " \"id\": 1,\n" + + " \"name\": \"cheri\",\n" + + " \"growth_time\": 3,\n" + + " \"max_harvest\": 5,\n" + + " \"natural_gift_power\": 60,\n" + + " \"size\": 20,\n" + + " \"smoothness\": 25,\n" + + " \"soil_dryness\": 15,\n" + + " \"firmness\": {\n" + + " \"name\": \"soft\",\n" + + " \"url\": \"https://pokeapi.co/api/v2/berry-firmness/2/\"\n" + + " },\n" + + " \"flavors\": [\n" + + " {\n" + + " \"potency\": 10,\n" + + " \"flavor\": {\n" + + " \"name\": \"spicy\",\n" + + " \"url\": \"https://pokeapi.co/api/v2/berry-flavor/1/\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"item\": {\n" + + " \"name\": \"cheri-berry\",\n" + + " \"url\": \"https://pokeapi.co/api/v2/item/126/\"\n" + + " },\n" + + " \"natural_gift_type\": {\n" + + " \"name\": \"fire\",\n" + + " \"url\": \"https://pokeapi.co/api/v2/type/10/\"\n" + + " }\n" + + "}" + ).toResponseBody("application/json".toMediaType()) + + // When + val berry = PokeApi.get(1) + // Then + assertInstanceOf(Berry::class.java, berry) + assertEquals(id, berry.id) + } +}