Skip to content

Commit

Permalink
Merge d2135d8 into d9ed70d
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgirro committed Apr 29, 2021
2 parents d9ed70d + d2135d8 commit b6bed7f
Show file tree
Hide file tree
Showing 73 changed files with 3,547 additions and 137 deletions.
293 changes: 285 additions & 8 deletions api/stalla.api

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ tasks {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
"-Xopt-in=dev.stalla.util.InternalAPI",
Expand Down
63 changes: 63 additions & 0 deletions src/main/kotlin/dev/stalla/builder/GeographicLocationBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package dev.stalla.builder

import dev.stalla.model.podcastindex.GeographicLocation
import dev.stalla.util.whenNotNull

/**
* Builder for constructing [GeographicLocation] instances.
*
* @since 1.1.0
*/
public interface GeographicLocationBuilder : Builder<GeographicLocation> {

/** Set the latitude value. */
public fun latitude(latitude: Double): GeographicLocationBuilder

/** Set the longitude value. */
public fun longitude(longitude: Double): GeographicLocationBuilder

/** Set the altitude value. */
public fun altitude(altitude: Double?): GeographicLocationBuilder

/** Set the crs value. */
public fun crs(crs: String?): GeographicLocationBuilder

/** Set the uncertainty value. */
public fun uncertainty(uncertainty: Double?): GeographicLocationBuilder

/** Adds a [GeographicLocation.Parameter] based on [key] and [value] to the list of parameters. */
public fun addParameter(key: String, value: String): GeographicLocationBuilder

/** Adds a [GeographicLocation.Parameter] to the list of parameters. */
public fun addParameter(parameter: GeographicLocation.Parameter): GeographicLocationBuilder =
apply { addParameter(parameter.key, parameter.value) }

/** Adds all [GeographicLocation.Parameter] to the list of parameters. */
public fun addAllParameters(parameters: List<GeographicLocation.Parameter>): GeographicLocationBuilder =
apply { parameters.forEach(::addParameter) }

/** Removes the parameter with [key] from the list of parameters. */
public fun removeParameter(key: String): GeographicLocationBuilder

/** Removes [parameter] from the list of parameters. */
public fun removeParameter(parameter: GeographicLocation.Parameter): GeographicLocationBuilder

/** Returns `true` if the coordA property is set. */
public fun hasLatitude(): Boolean

/** Returns `true` if the coordB property is set. */
public fun hasLongitude(): Boolean

/** Returns `true` if the coordC property is set. */
public fun hasAltitude(): Boolean

override fun applyFrom(prototype: GeographicLocation?): GeographicLocationBuilder =
whenNotNull(prototype) { location ->
latitude(location.latitude)
longitude(location.longitude)
altitude(location.altitude)
crs(location.crs)
uncertainty(location.uncertainty)
addAllParameters(location.parameters)
}
}
29 changes: 29 additions & 0 deletions src/main/kotlin/dev/stalla/builder/OpenStreetMapElementBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.stalla.builder

import dev.stalla.model.podcastindex.OpenStreetMapElement
import dev.stalla.model.podcastindex.OpenStreetMapElementType
import dev.stalla.util.whenNotNull

/**
* Builder for constructing [OpenStreetMapElement] instances.
*
* @since 1.1.0
*/
public interface OpenStreetMapElementBuilder : Builder<OpenStreetMapElement> {

/** Set the type value. */
public fun type(type: OpenStreetMapElementType): OpenStreetMapElementBuilder

/** Set the id value. */
public fun id(id: Long): OpenStreetMapElementBuilder = apply { id(id) }

/** Set the revision value. */
public fun revision(revision: Int?): OpenStreetMapElementBuilder = apply { revision(revision) }

override fun applyFrom(prototype: OpenStreetMapElement?): OpenStreetMapElementBuilder =
whenNotNull(prototype) { feature ->
type(feature.type)
id(feature.id)
revision(feature.revision)
}
}
30 changes: 30 additions & 0 deletions src/main/kotlin/dev/stalla/builder/PodcastindexLocationBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dev.stalla.builder

import dev.stalla.model.podcastindex.GeographicLocation
import dev.stalla.model.podcastindex.OpenStreetMapElement
import dev.stalla.model.podcastindex.PodcastindexLocation
import dev.stalla.util.whenNotNull

/**
* Builder for constructing [PodcastindexLocation] instances.
*
* @since 1.1.0
*/
public interface PodcastindexLocationBuilder : Builder<PodcastindexLocation> {

/** Set the name value. */
public fun name(name: String): PodcastindexLocationBuilder

/** Set the geo value. */
public fun geo(geo: GeographicLocation?): PodcastindexLocationBuilder

/** Set the osm value. */
public fun osm(osm: OpenStreetMapElement?): PodcastindexLocationBuilder

override fun applyFrom(prototype: PodcastindexLocation?): PodcastindexLocationBuilder =
whenNotNull(prototype) { location ->
name(location.name)
geo(GeographicLocation.builder().applyFrom(location.geo).build())
osm(OpenStreetMapElement.builder().applyFrom(location.osm).build())
}
}
36 changes: 36 additions & 0 deletions src/main/kotlin/dev/stalla/builder/PodcastindexPersonBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.stalla.builder

import dev.stalla.model.podcastindex.PodcastindexPerson
import dev.stalla.util.whenNotNull

/**
* Builder for constructing [PodcastindexPerson] instances.
*
* @since 1.1.0
*/
public interface PodcastindexPersonBuilder : Builder<PodcastindexPerson> {

/** Set the name value. */
public fun name(name: String): PodcastindexPersonBuilder

/** Set the role value. */
public fun role(role: String?): PodcastindexPersonBuilder

/** Set the group value. */
public fun group(group: String?): PodcastindexPersonBuilder

/** Set the img value. */
public fun img(img: String?): PodcastindexPersonBuilder

/** Set the href value. */
public fun href(href: String?): PodcastindexPersonBuilder

override fun applyFrom(prototype: PodcastindexPerson?): PodcastindexPersonBuilder =
whenNotNull(prototype) { person ->
name(person.name)
role(person.role)
group(person.group)
img(person.img)
href(person.href)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package dev.stalla.builder.episode

import dev.stalla.builder.Builder
import dev.stalla.builder.PodcastindexLocationBuilder
import dev.stalla.builder.PodcastindexPersonBuilder
import dev.stalla.model.podcastindex.Chapters
import dev.stalla.model.podcastindex.EpisodePodcastindex
import dev.stalla.model.podcastindex.PodcastindexEpisode
import dev.stalla.model.podcastindex.PodcastindexLocation
import dev.stalla.model.podcastindex.PodcastindexSeason
import dev.stalla.util.asBuilders
import dev.stalla.util.whenNotNull

Expand All @@ -14,7 +19,7 @@ import dev.stalla.util.whenNotNull
public interface EpisodePodcastindexBuilder : Builder<EpisodePodcastindex> {

/**
* Set the [EpisodePodcastindexChaptersBuilder] for the Podcastindex namespace `<chapters>` info.
* Set the [EpisodePodcastindexChaptersBuilder] for the Podcastindex namespace `<podcast:chapters>` info.
*/
public fun chaptersBuilder(chaptersBuilder: EpisodePodcastindexChaptersBuilder): EpisodePodcastindexBuilder

Expand Down Expand Up @@ -52,10 +57,45 @@ public interface EpisodePodcastindexBuilder : Builder<EpisodePodcastindex> {
transcriptBuilders.forEach(::addTranscriptBuilder)
}

/**
* Adds the [PodcastindexPersonBuilder] for the
* `<podcast:person>` info to the list of person builders.
*/
public fun addPersonBuilder(personBuilder: PodcastindexPersonBuilder): EpisodePodcastindexBuilder

/**
* Adds all of the [PodcastindexPersonBuilder] for the
* `<podcast:person>` info to the list of person builders.
*/
public fun addAllPersonBuilders(
personBuilders: List<PodcastindexPersonBuilder>
): EpisodePodcastindexBuilder = apply {
personBuilders.forEach(::addPersonBuilder)
}

/**
* Set the [PodcastindexLocationBuilder] for the Podcastindex namespace `<podcast:location>` info.
*/
public fun locationBuilder(locationBuilder: PodcastindexLocationBuilder): EpisodePodcastindexBuilder

/**
* Set the [EpisodePodcastindexSeasonBuilder] for the Podcastindex namespace `<podcast:season>` info.
*/
public fun seasonBuilder(seasonBuilder: EpisodePodcastindexSeasonBuilder): EpisodePodcastindexBuilder

/**
* Set the [EpisodePodcastindexEpisodeBuilder] for the Podcastindex namespace `<podcast:episode>` info.
*/
public fun episodeBuilder(episodeBuilder: EpisodePodcastindexEpisodeBuilder): EpisodePodcastindexBuilder

override fun applyFrom(prototype: EpisodePodcastindex?): EpisodePodcastindexBuilder =
whenNotNull(prototype) { podcast ->
chaptersBuilder(Chapters.builder().applyFrom(podcast.chapters))
addAllSoundbiteBuilders(podcast.soundbites.asBuilders())
addAllTranscriptBuilders(podcast.transcripts.asBuilders())
addAllPersonBuilders(podcast.persons.asBuilders())
locationBuilder(PodcastindexLocation.builder().applyFrom(podcast.location))
seasonBuilder(PodcastindexSeason.builder().applyFrom(podcast.season))
episodeBuilder(PodcastindexEpisode.builder().applyFrom(podcast.episode))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package dev.stalla.builder.episode

import dev.stalla.builder.Builder
import dev.stalla.model.podcastindex.PodcastindexEpisode
import dev.stalla.util.whenNotNull

/**
* Builder for constructing [PodcastindexEpisode] instances.
*
* @since 1.1.0
*/
public interface EpisodePodcastindexEpisodeBuilder : Builder<PodcastindexEpisode> {

/** Set the number value. */
public fun number(number: Double): EpisodePodcastindexEpisodeBuilder

/** Set the display value. */
public fun display(display: String?): EpisodePodcastindexEpisodeBuilder

override fun applyFrom(prototype: PodcastindexEpisode?): EpisodePodcastindexEpisodeBuilder =
whenNotNull(prototype) { episode ->
number(episode.number)
display(episode.display)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package dev.stalla.builder.episode

import dev.stalla.builder.Builder
import dev.stalla.model.podcastindex.PodcastindexSeason
import dev.stalla.util.whenNotNull

/**
* Builder for constructing [PodcastindexSeason] instances.
*
* @since 1.1.0
*/
public interface EpisodePodcastindexSeasonBuilder : Builder<PodcastindexSeason> {

/** Set the number value. */
public fun number(number: Int): EpisodePodcastindexSeasonBuilder

/** Set the name value. */
public fun name(name: String?): EpisodePodcastindexSeasonBuilder

override fun applyFrom(prototype: PodcastindexSeason?): EpisodePodcastindexSeasonBuilder =
whenNotNull(prototype) { season ->
number(season.number)
name(season.name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package dev.stalla.builder.episode
import dev.stalla.builder.AtomPersonBuilderProvider
import dev.stalla.builder.HrefOnlyImageBuilder
import dev.stalla.builder.LinkBuilderProvider
import dev.stalla.builder.PodcastindexLocationBuilder
import dev.stalla.builder.PodcastindexPersonBuilder
import dev.stalla.builder.RssCategoryBuilder
import dev.stalla.util.InternalAPI

Expand Down Expand Up @@ -32,4 +34,16 @@ internal interface ProvidingEpisodeBuilder : EpisodeBuilder, AtomPersonBuilderPr

/** Creates an instance of [EpisodePodcastindexSoundbiteBuilder] to use with this builder. */
fun createSoundbiteBuilder(): EpisodePodcastindexSoundbiteBuilder

/** Creates an instance of [PodcastindexPersonBuilder] to use with this builder. */
fun createPersonBuilder(): PodcastindexPersonBuilder

/** Creates an instance of [PodcastindexLocationBuilder] to use with this builder. */
fun createLocationBuilder(): PodcastindexLocationBuilder

/** Creates an instance of [EpisodePodcastindexSeasonBuilder] to use with this builder. */
fun createSeasonBuilder(): EpisodePodcastindexSeasonBuilder

/** Creates an instance of [EpisodePodcastindexEpisodeBuilder] to use with this builder. */
fun createEpisodeBuilder(): EpisodePodcastindexEpisodeBuilder
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package dev.stalla.builder.podcast

import dev.stalla.builder.Builder
import dev.stalla.builder.PodcastindexLocationBuilder
import dev.stalla.builder.PodcastindexPersonBuilder
import dev.stalla.model.podcastindex.Locked
import dev.stalla.model.podcastindex.PodcastPodcastindex
import dev.stalla.model.podcastindex.PodcastindexLocation
import dev.stalla.util.asBuilders
import dev.stalla.util.whenNotNull

Expand Down Expand Up @@ -32,9 +35,30 @@ public interface PodcastPodcastindexBuilder : Builder<PodcastPodcastindex> {
fundingBuilders.forEach(::addFundingBuilder)
}

/**
* Adds the [PodcastindexPersonBuilder] for the
* `<podcast:person>` info to the list of person builders.
*/
public fun addPersonBuilder(personBuilder: PodcastindexPersonBuilder): PodcastPodcastindexBuilder

/**
* Adds all of the [PodcastindexPersonBuilder] for the
* `<podcast:person>` info to the list of person builders.
*/
public fun addAllPersonBuilders(
personBuilders: List<PodcastindexPersonBuilder>
): PodcastPodcastindexBuilder = apply {
personBuilders.forEach(::addPersonBuilder)
}

/** Set the [PodcastindexLocationBuilder]. */
public fun locationBuilder(locationBuilder: PodcastindexLocationBuilder): PodcastPodcastindexBuilder

override fun applyFrom(prototype: PodcastPodcastindex?): PodcastPodcastindexBuilder =
whenNotNull(prototype) { podcast ->
lockedBuilder(Locked.builder().applyFrom(podcast.locked))
addAllFundingBuilders(podcast.funding.asBuilders())
addAllPersonBuilders(podcast.persons.asBuilders())
locationBuilder(PodcastindexLocation.builder().applyFrom(podcast.location))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package dev.stalla.builder.podcast
import dev.stalla.builder.AtomPersonBuilderProvider
import dev.stalla.builder.HrefOnlyImageBuilder
import dev.stalla.builder.LinkBuilderProvider
import dev.stalla.builder.PodcastindexLocationBuilder
import dev.stalla.builder.PodcastindexPersonBuilder
import dev.stalla.builder.RssCategoryBuilder
import dev.stalla.builder.RssImageBuilder

Expand All @@ -25,4 +27,10 @@ internal interface ProvidingPodcastBuilder : PodcastBuilder, AtomPersonBuilderPr

/** Creates an instance of [PodcastPodcastindexFundingBuilder] to use with this builder. */
fun createFundingBuilder(): PodcastPodcastindexFundingBuilder

/** Creates an instance of [PodcastindexPersonBuilder] to use with this builder. */
fun createPersonBuilder(): PodcastindexPersonBuilder

/** Creates an instance of [PodcastindexLocationBuilder] to use with this builder. */
fun createLocationBuilder(): PodcastindexLocationBuilder
}
Loading

0 comments on commit b6bed7f

Please sign in to comment.