Skip to content

Commit

Permalink
Merge pull request #59 from mpgirro/v1.0_cleanup
Browse files Browse the repository at this point in the history
v1.0 cleanup
  • Loading branch information
rock3r committed Mar 3, 2021
2 parents 8743810 + dde9d60 commit 4806b24
Show file tree
Hide file tree
Showing 116 changed files with 1,480 additions and 960 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ repositories {
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
implementation("com.google.guava:guava:30.1-android")

testImplementation("org.junit.jupiter:junit-jupiter-engine:$junit5Version")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junit5Version")
Expand Down
26 changes: 13 additions & 13 deletions src/main/kotlin/dev/stalla/builder/AtomBuilder.kt
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
package dev.stalla.builder

import dev.stalla.model.Person
import dev.stalla.model.atom.Atom
import dev.stalla.model.atom.AtomPerson
import dev.stalla.model.atom.Link
import dev.stalla.util.whenNotNull

/** Builder for constructing [Atom] instances. */
public interface AtomBuilder : Builder<Atom> {

/** Adds the [PersonBuilder] to the list of author builders. */
public fun addAuthorBuilder(authorBuilder: PersonBuilder): AtomBuilder
/** Adds the [AtomPersonBuilder] to the list of author builders. */
public fun addAuthorBuilder(authorBuilder: AtomPersonBuilder): AtomBuilder

/** Adds all of the [PersonBuilder] to the list of author builders. */
public fun addAllAuthorBuilder(authorBuilders: List<PersonBuilder>): AtomBuilder =
/** Adds all of the [AtomPersonBuilder] to the list of author builders. */
public fun addAllAuthorBuilders(authorBuilders: List<AtomPersonBuilder>): AtomBuilder =
apply { authorBuilders.forEach(::addAuthorBuilder) }

/** Adds the [PersonBuilder] to the list of contributor builders. */
public fun addContributorBuilder(contributorBuilder: PersonBuilder): AtomBuilder
/** Adds the [AtomPersonBuilder] to the list of contributor builders. */
public fun addContributorBuilder(contributorBuilder: AtomPersonBuilder): AtomBuilder

/** Adds all of the [PersonBuilder] to the list of contributor builders. */
public fun addAllContributorBuilder(contributorBuilders: List<PersonBuilder>): AtomBuilder =
/** Adds all of the [AtomPersonBuilder] to the list of contributor builders. */
public fun addAllContributorBuilders(contributorBuilders: List<AtomPersonBuilder>): AtomBuilder =
apply { contributorBuilders.forEach(::addContributorBuilder) }

/** Adds the [LinkBuilder] to the list of links. */
public fun addLinkBuilder(linkBuilder: LinkBuilder): AtomBuilder

/** Adds all of the [LinkBuilder] to the list of links. */
public fun addAllLinkBuilder(linkBuilders: List<LinkBuilder>): AtomBuilder =
public fun addAllLinkBuilders(linkBuilders: List<LinkBuilder>): AtomBuilder =
apply { linkBuilders.forEach(::addLinkBuilder) }

override fun applyFrom(prototype: Atom?): AtomBuilder =
whenNotNull(prototype) { atom ->
addAllAuthorBuilder(atom.authors.map(Person.builder()::applyFrom))
addAllContributorBuilder(atom.contributors.map(Person.builder()::applyFrom))
addAllLinkBuilder(atom.links.map(Link.builder()::applyFrom))
addAllAuthorBuilders(atom.authors.map(AtomPerson.builder()::applyFrom))
addAllContributorBuilders(atom.contributors.map(AtomPerson.builder()::applyFrom))
addAllLinkBuilders(atom.links.map(Link.builder()::applyFrom))
}
}
24 changes: 24 additions & 0 deletions src/main/kotlin/dev/stalla/builder/AtomPersonBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.stalla.builder

import dev.stalla.model.atom.AtomPerson
import dev.stalla.util.whenNotNull

/** Builder for constructing [AtomPerson] instances. */
public interface AtomPersonBuilder : Builder<AtomPerson> {

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

/** Set the email value. */
public fun email(email: String?): AtomPersonBuilder

/** Set the uri value. */
public fun uri(uri: String?): AtomPersonBuilder

override fun applyFrom(prototype: AtomPerson?): AtomPersonBuilder =
whenNotNull(prototype) { person ->
name(person.name)
email(person.email)
uri(person.uri)
}
}
10 changes: 10 additions & 0 deletions src/main/kotlin/dev/stalla/builder/AtomPersonBuilderProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.stalla.builder

import dev.stalla.util.InternalApi

@InternalApi
internal interface AtomPersonBuilderProvider {

/** Creates an instance of [AtomPersonBuilder] to use with this builder. */
fun createAtomPersonBuilder(): AtomPersonBuilder
}
3 changes: 2 additions & 1 deletion src/main/kotlin/dev/stalla/builder/LinkBuilder.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.stalla.builder

import com.google.common.net.MediaType
import dev.stalla.model.atom.Link
import dev.stalla.util.whenNotNull

Expand All @@ -25,7 +26,7 @@ public interface LinkBuilder : Builder<Link> {
public fun title(title: String?): LinkBuilder

/** Set the type value. */
public fun type(type: String?): LinkBuilder
public fun type(type: MediaType?): LinkBuilder

override fun applyFrom(prototype: Link?): LinkBuilder =
whenNotNull(prototype) { link ->
Expand Down
24 changes: 0 additions & 24 deletions src/main/kotlin/dev/stalla/builder/PersonBuilder.kt

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/kotlin/dev/stalla/builder/PersonBuilderProvider.kt

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/kotlin/dev/stalla/builder/episode/EpisodeBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface EpisodeBuilder : Builder<Episode> {
public fun addCategoryBuilder(categoryBuilder: RssCategoryBuilder): EpisodeBuilder

/** Adds all of the [RssCategoryBuilder] to the list of category builders. */
public fun addAllCategoryBuilder(categoryBuilders: List<RssCategoryBuilder>): EpisodeBuilder =
public fun addAllCategoryBuilders(categoryBuilders: List<RssCategoryBuilder>): EpisodeBuilder =
apply { categoryBuilders.forEach(::addCategoryBuilder) }

/** Set the comments value. */
Expand Down Expand Up @@ -81,7 +81,7 @@ public interface EpisodeBuilder : Builder<Episode> {
link(episode.link)
description(episode.description)
author(episode.author)
addAllCategoryBuilder(episode.categories.asBuilders())
addAllCategoryBuilders(episode.categories.asBuilders())
comments(episode.comments)
enclosureBuilder(Enclosure.builder().applyFrom(episode.enclosure))
guidBuilder(Guid.builder().applyFrom(episode.guid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface EpisodePodcastindexBuilder : Builder<EpisodePodcastindex> {
* Adds all of the [EpisodePodcastindexSoundbiteBuilder] for the
* `<podcast:soundbite>` info to the list of soundbite builders.
*/
public fun addAllSoundbiteBuilder(
public fun addAllSoundbiteBuilders(
soundbiteBuilders: List<EpisodePodcastindexSoundbiteBuilder>
): EpisodePodcastindexBuilder = apply {
soundbiteBuilders.forEach(::addSoundbiteBuilder)
Expand All @@ -42,7 +42,7 @@ public interface EpisodePodcastindexBuilder : Builder<EpisodePodcastindex> {
* Adds all of the [EpisodePodcastindexTranscriptBuilder] for the
* `<podcast:transcript>` info to the list of transcript builders.
*/
public fun addAllTranscriptBuilder(
public fun addAllTranscriptBuilders(
transcriptBuilders: List<EpisodePodcastindexTranscriptBuilder>
): EpisodePodcastindexBuilder = apply {
transcriptBuilders.forEach(::addTranscriptBuilder)
Expand All @@ -51,7 +51,7 @@ public interface EpisodePodcastindexBuilder : Builder<EpisodePodcastindex> {
override fun applyFrom(prototype: EpisodePodcastindex?): EpisodePodcastindexBuilder =
whenNotNull(prototype) { podcast ->
chaptersBuilder(Chapters.builder().applyFrom(podcast.chapters))
addAllSoundbiteBuilder(podcast.soundbites.asBuilders())
addAllTranscriptBuilder(podcast.transcripts.asBuilders())
addAllSoundbiteBuilders(podcast.soundbites.asBuilders())
addAllTranscriptBuilders(podcast.transcripts.asBuilders())
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.stalla.builder.episode

import com.google.common.net.MediaType
import dev.stalla.builder.Builder
import dev.stalla.model.podcastindex.Chapters
import dev.stalla.util.whenNotNull
Expand All @@ -11,7 +12,7 @@ public interface EpisodePodcastindexChaptersBuilder : Builder<Chapters> {
public fun url(url: String): EpisodePodcastindexChaptersBuilder

/** Set the type value. */
public fun type(type: String): EpisodePodcastindexChaptersBuilder
public fun type(type: MediaType): EpisodePodcastindexChaptersBuilder

override fun applyFrom(prototype: Chapters?): EpisodePodcastindexChaptersBuilder =
whenNotNull(prototype) { chapters ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public interface EpisodePodloveBuilder : Builder<EpisodePodlove> {
public fun addSimpleChapterBuilder(chapterBuilder: EpisodePodloveSimpleChapterBuilder): EpisodePodloveBuilder

/** Adds all of the [EpisodePodloveSimpleChapterBuilder] to the list of chapter builders. */
public fun addAllSimpleChapterBuilder(
public fun addAllSimpleChapterBuilders(
chapterBuilders: List<EpisodePodloveSimpleChapterBuilder>
): EpisodePodloveBuilder

override fun applyFrom(prototype: EpisodePodlove?): EpisodePodloveBuilder =
whenNotNull(prototype) { podlove -> addAllSimpleChapterBuilder(podlove.simpleChapters.asBuilders()) }
whenNotNull(prototype) { podlove -> addAllSimpleChapterBuilders(podlove.simpleChapters.asBuilders()) }
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.stalla.builder.episode

import dev.stalla.builder.AtomPersonBuilderProvider
import dev.stalla.builder.HrefOnlyImageBuilder
import dev.stalla.builder.LinkBuilderProvider
import dev.stalla.builder.PersonBuilderProvider
import dev.stalla.builder.RssCategoryBuilder
import dev.stalla.util.InternalApi

@InternalApi
internal interface ProvidingEpisodeBuilder : EpisodeBuilder, PersonBuilderProvider, LinkBuilderProvider {
internal interface ProvidingEpisodeBuilder : EpisodeBuilder, AtomPersonBuilderProvider, LinkBuilderProvider {

/** Creates an instance of [EpisodeEnclosureBuilder] to use with this builder. */
fun createEnclosureBuilder(): EpisodeEnclosureBuilder
Expand All @@ -19,17 +19,17 @@ internal interface ProvidingEpisodeBuilder : EpisodeBuilder, PersonBuilderProvid
fun createHrefOnlyImageBuilder(): HrefOnlyImageBuilder

/** Creates an instance of [EpisodePodloveSimpleChapterBuilder] to use with this builder. */
fun createPodloveSimpleChapterBuilder(): EpisodePodloveSimpleChapterBuilder
fun createSimpleChapterBuilder(): EpisodePodloveSimpleChapterBuilder

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

/** Creates an instance of [EpisodePodcastindexTranscriptBuilder] to use with this builder. */
fun createEpisodePodcastTranscriptBuilder(): EpisodePodcastindexTranscriptBuilder
fun createTranscriptBuilder(): EpisodePodcastindexTranscriptBuilder

/** Creates an instance of [EpisodePodcastindexChaptersBuilder] to use with this builder. */
fun createEpisodePodcastChaptersBuilder(): EpisodePodcastindexChaptersBuilder
fun createChaptersBuilder(): EpisodePodcastindexChaptersBuilder

/** Creates an instance of [EpisodePodcastindexSoundbiteBuilder] to use with this builder. */
fun createEpisodePodcastSoundbiteBuilder(): EpisodePodcastindexSoundbiteBuilder
fun createSoundbiteBuilder(): EpisodePodcastindexSoundbiteBuilder
}
11 changes: 6 additions & 5 deletions src/main/kotlin/dev/stalla/builder/podcast/PodcastBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import dev.stalla.model.rss.RssImage
import dev.stalla.util.asBuilders
import dev.stalla.util.whenNotNull
import java.time.temporal.TemporalAccessor
import java.util.Locale

/** Builder for constructing [Podcast] instances. */
public interface PodcastBuilder : Builder<Podcast> {
Expand Down Expand Up @@ -48,7 +49,7 @@ public interface PodcastBuilder : Builder<Podcast> {
public fun lastBuildDate(lastBuildDate: TemporalAccessor?): PodcastBuilder

/** Set the language value. */
public fun language(language: String): PodcastBuilder
public fun language(language: Locale): PodcastBuilder

/** Set the generator value. */
public fun generator(generator: String?): PodcastBuilder
Expand All @@ -75,14 +76,14 @@ public interface PodcastBuilder : Builder<Podcast> {
public fun addEpisodeBuilder(episodeBuilder: EpisodeBuilder): PodcastBuilder

/** Adds all of the [EpisodeBuilder] to the list of episode builders. */
public fun addAllEpisodeBuilder(episodeBuilders: List<EpisodeBuilder>): PodcastBuilder =
public fun addAllEpisodeBuilders(episodeBuilders: List<EpisodeBuilder>): PodcastBuilder =
apply { episodeBuilders.forEach(::addEpisodeBuilder) }

/** Adds the [RssCategoryBuilder] to the list of category builders. */
public fun addCategoryBuilder(categoryBuilder: RssCategoryBuilder): PodcastBuilder

/** Adds all of the [RssCategoryBuilder] to the list of category builders. */
public fun addAllCategoryBuilder(categoryBuilders: List<RssCategoryBuilder>): PodcastBuilder =
public fun addAllCategoryBuilders(categoryBuilders: List<RssCategoryBuilder>): PodcastBuilder =
apply { categoryBuilders.forEach(::addCategoryBuilder) }

override fun applyFrom(prototype: Podcast?): PodcastBuilder =
Expand All @@ -106,7 +107,7 @@ public interface PodcastBuilder : Builder<Podcast> {
webMaster(podcast.webMaster)
ttl(podcast.ttl)
imageBuilder(RssImage.builder().applyFrom(podcast.image))
addAllEpisodeBuilder(podcast.episodes.asBuilders())
addAllCategoryBuilder(podcast.categories.asBuilders())
addAllEpisodeBuilders(podcast.episodes.asBuilders())
addAllCategoryBuilders(podcast.categories.asBuilders())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.stalla.builder.podcast
import dev.stalla.builder.Builder
import dev.stalla.model.feedpress.Feedpress
import dev.stalla.util.whenNotNull
import java.util.Locale

/** Builder for constructing [Feedpress] instances. */
public interface PodcastFeedpressBuilder : Builder<Feedpress> {
Expand All @@ -11,7 +12,7 @@ public interface PodcastFeedpressBuilder : Builder<Feedpress> {
public fun newsletterId(newsletterId: String?): PodcastFeedpressBuilder

/** Set the locale value. */
public fun locale(locale: String?): PodcastFeedpressBuilder
public fun locale(locale: Locale?): PodcastFeedpressBuilder

/** Set the podcastId value. */
public fun podcastId(podcastId: String?): PodcastFeedpressBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public interface PodcastGoogleplayBuilder : Builder<PodcastGoogleplay> {
public fun author(author: String?): PodcastGoogleplayBuilder

/** Set the owner email value. */
public fun owner(email: String?): PodcastGoogleplayBuilder
public fun email(email: String?): PodcastGoogleplayBuilder

/** Adds the [GoogleplayCategory] the list of categories. */
public fun addCategory(category: GoogleplayCategory): PodcastGoogleplayBuilder

/** Adds all of the [GoogleplayCategory] to the list of categories. */
public fun addAllCategorie(categories: List<GoogleplayCategory>): PodcastGoogleplayBuilder =
public fun addAllCategories(categories: List<GoogleplayCategory>): PodcastGoogleplayBuilder =
apply { categories.forEach(::addCategory) }

/** Set the description value. */
Expand All @@ -41,8 +41,8 @@ public interface PodcastGoogleplayBuilder : Builder<PodcastGoogleplay> {
override fun applyFrom(prototype: PodcastGoogleplay?): PodcastGoogleplayBuilder =
whenNotNull(prototype) { googleplay ->
author(googleplay.author)
owner(googleplay.owner)
addAllCategorie(googleplay.categories)
email(googleplay.email)
addAllCategories(googleplay.categories)
description(googleplay.description)
explicit(googleplay.explicit)
block(googleplay.block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package dev.stalla.builder.podcast

import dev.stalla.builder.Builder
import dev.stalla.builder.HrefOnlyImageBuilder
import dev.stalla.builder.PersonBuilder
import dev.stalla.model.HrefOnlyImage
import dev.stalla.model.Person
import dev.stalla.model.itunes.ItunesCategory
import dev.stalla.model.itunes.ItunesOwner
import dev.stalla.model.itunes.PodcastItunes
import dev.stalla.util.whenNotNull

Expand All @@ -31,7 +30,7 @@ public interface PodcastItunesBuilder : Builder<PodcastItunes> {
public fun addCategory(category: ItunesCategory): PodcastItunesBuilder

/** Adds all of the [ItunesCategory] to the list of categories. */
public fun addAllCategory(categories: List<ItunesCategory>): PodcastItunesBuilder =
public fun addAllCategories(categories: List<ItunesCategory>): PodcastItunesBuilder =
apply { categories.forEach(::addCategory) }

/** Set the explicit flag value. */
Expand All @@ -47,7 +46,7 @@ public interface PodcastItunesBuilder : Builder<PodcastItunes> {
public fun type(type: String?): PodcastItunesBuilder

/** Set the Person representing the owner. */
public fun ownerBuilder(ownerBuilder: PersonBuilder?): PodcastItunesBuilder
public fun ownerBuilder(ownerBuilder: PodcastItunesOwnerBuilder?): PodcastItunesBuilder

/** Set the episode title. */
public fun title(title: String?): PodcastItunesBuilder
Expand All @@ -62,12 +61,12 @@ public interface PodcastItunesBuilder : Builder<PodcastItunes> {
imageBuilder(HrefOnlyImage.builder().applyFrom(itunes.image))
keywords(itunes.keywords)
author(itunes.author)
addAllCategory(itunes.categories)
addAllCategories(itunes.categories)
explicit(itunes.explicit)
block(itunes.block)
complete(itunes.complete)
type(itunes.type?.type)
ownerBuilder(Person.builder().applyFrom(itunes.owner))
ownerBuilder(ItunesOwner.builder().applyFrom(itunes.owner))
title(itunes.title)
newFeedUrl(itunes.newFeedUrl)
}
Expand Down

0 comments on commit 4806b24

Please sign in to comment.