Skip to content

Commit

Permalink
Merge pull request #93 from mpgirro/89_deprecation
Browse files Browse the repository at this point in the history
Deprecations for v1.1.0
  • Loading branch information
rock3r committed May 4, 2021
2 parents d638706 + dd60da1 commit 7f88528
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 55 deletions.
7 changes: 5 additions & 2 deletions api/stalla.api
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ public abstract interface class dev/stalla/builder/podcast/PodcastBuilder : dev/
public abstract fun getGoogleplayBuilder ()Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public abstract fun getItunesBuilder ()Ldev/stalla/builder/podcast/PodcastItunesBuilder;
public abstract fun getPodcastPodcastindexBuilder ()Ldev/stalla/builder/podcast/PodcastPodcastindexBuilder;
public abstract fun getPodcastindexBuilder ()Ldev/stalla/builder/podcast/PodcastPodcastindexBuilder;
public abstract fun imageBuilder (Ldev/stalla/builder/RssImageBuilder;)Ldev/stalla/builder/podcast/PodcastBuilder;
public abstract fun language (Ljava/util/Locale;)Ldev/stalla/builder/podcast/PodcastBuilder;
public abstract fun lastBuildDate (Ljava/time/temporal/TemporalAccessor;)Ldev/stalla/builder/podcast/PodcastBuilder;
Expand Down Expand Up @@ -629,6 +630,8 @@ public class dev/stalla/model/MediaType {
public fun hashCode ()I
public final fun match (Ldev/stalla/model/MediaType;)Z
public final fun match (Ljava/lang/String;)Z
public final fun matches (Ldev/stalla/model/MediaType;)Z
public final fun matches (Ljava/lang/String;)Z
public static fun of (Ljava/lang/String;)Ldev/stalla/model/MediaType;
public final fun parameter (Ljava/lang/String;)Ljava/lang/String;
public fun toString ()Ljava/lang/String;
Expand Down Expand Up @@ -1416,8 +1419,8 @@ public final class dev/stalla/model/podcastindex/GeographicLocation {
public final fun getParameters ()Ljava/util/List;
public final fun getUncertainty ()Ljava/lang/Double;
public fun hashCode ()I
public final fun match (Ldev/stalla/model/podcastindex/GeographicLocation;)Z
public final fun match (Ljava/lang/String;)Z
public final fun matches (Ldev/stalla/model/podcastindex/GeographicLocation;)Z
public final fun matches (Ljava/lang/String;)Z
public static fun of (Ljava/lang/String;)Ldev/stalla/model/podcastindex/GeographicLocation;
public final fun parameter (Ljava/lang/String;)Ljava/lang/String;
public fun toString ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface EpisodeBuilder : Builder<Episode> {
/** The builder for data from the Bitlove namespace. */
public val bitloveBuilder: EpisodeBitloveBuilder

/** The builder for data from the Podcast namespace. */
/** The builder for data from the Podcastindex namespace. */
public val podcastindexBuilder: EpisodePodcastindexBuilder

/** Set the title value. */
Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/dev/stalla/builder/podcast/PodcastBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ public interface PodcastBuilder : Builder<Podcast> {
/** The builder for data from the Google Play namespace. */
public val googleplayBuilder: PodcastGoogleplayBuilder

/** Set the Podcast namespace builder. */
/** The builder for data from the Podcastindex namespace. */
public val podcastindexBuilder: PodcastPodcastindexBuilder

/** The builder for data from the Podcastindex namespace. */
@Deprecated(
message = "This property is scheduled for removal in v2.0.0",
replaceWith = ReplaceWith("podcastindexBuilder")
)
public val podcastPodcastindexBuilder: PodcastPodcastindexBuilder

/** Set the title value. */
Expand Down Expand Up @@ -97,7 +104,7 @@ public interface PodcastBuilder : Builder<Podcast> {
fyydBuilder.applyFrom(podcast.fyyd)
feedpressBuilder.applyFrom(podcast.feedpress)
googleplayBuilder.applyFrom(podcast.googleplay)
podcastPodcastindexBuilder.applyFrom(podcast.podcastindex)
podcastindexBuilder.applyFrom(podcast.podcastindex)
title(podcast.title)
link(podcast.link)
description(podcast.description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ internal class ValidatingPodcastBuilder : ProvidingPodcastBuilder {

override val googleplayBuilder: PodcastGoogleplayBuilder = ValidatingPodcastGoogleplayBuilder()

override val podcastPodcastindexBuilder: PodcastPodcastindexBuilder = ValidatingPodcastPodcastindexBuilder()
override val podcastindexBuilder: PodcastPodcastindexBuilder = ValidatingPodcastPodcastindexBuilder()

override val podcastPodcastindexBuilder: PodcastPodcastindexBuilder by this::podcastindexBuilder

override fun title(title: String): PodcastBuilder = apply { this.titleValue = title }

Expand Down Expand Up @@ -156,7 +158,7 @@ internal class ValidatingPodcastBuilder : ProvidingPodcastBuilder {
feedpress = feedpressBuilder.build(),
googleplay = googleplayBuilder.build(),
categories = categoryBuilders.mapNotNull { it.build() }.asUnmodifiable(),
podcastindex = podcastPodcastindexBuilder.build()
podcastindex = podcastindexBuilder.build()
)
}
}
25 changes: 23 additions & 2 deletions src/main/kotlin/dev/stalla/model/MediaType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ public open class MediaType private constructor(

/**
* Checks if `this` type matches a [pattern] type taking into account placeholder symbols `*` and parameters.
* @since 1.1.0
*/
public fun match(pattern: MediaType?): Boolean {
public fun matches(pattern: MediaType?): Boolean {
contract {
returns(true) implies (pattern != null)
}
Expand All @@ -108,8 +109,28 @@ public open class MediaType private constructor(
/**
* Checks if `this` type matches a [pattern] type taking
* into account placeholder symbols `*` and parameters.
* @since 1.1.0
*/
public fun match(pattern: String): Boolean = match(of(pattern))
public fun matches(pattern: String): Boolean = matches(of(pattern))

/**
* Checks if `this` type matches a [pattern] type taking into account placeholder symbols `*` and parameters.
*/
@Deprecated(
message = "This method is scheduled for removal in v2.0.0",
replaceWith = ReplaceWith("matches")
)
public fun match(pattern: MediaType?): Boolean = matches(pattern)

/**
* Checks if `this` type matches a [pattern] type taking
* into account placeholder symbols `*` and parameters.
*/
@Deprecated(
message = "This method is scheduled for removal in v2.0.0",
replaceWith = ReplaceWith("matches")
)
public fun match(pattern: String): Boolean = matches(pattern)

private fun match(parameters1: List<Parameter>, parameters2: List<Parameter>): Boolean {
for ((patternName, patternValue) in parameters1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class GeographicLocation public constructor(
public fun withoutParameters(): GeographicLocation = GeographicLocation(latitude, longitude, altitude)

/** Checks if `this` type matches a [pattern] type taking parameters into account. */
public fun match(pattern: GeographicLocation?): Boolean {
public fun matches(pattern: GeographicLocation?): Boolean {
contract {
returns(true) implies (pattern != null)
}
Expand All @@ -132,7 +132,7 @@ public class GeographicLocation public constructor(
}

/** Checks if `this` type matches a [pattern] type taking parameters into account. */
public fun match(pattern: String): Boolean = match(of(pattern))
public fun matches(pattern: String): Boolean = matches(of(pattern))

private fun match(parameters1: List<Parameter>, parameters2: List<Parameter>): Boolean {
for (param1 in parameters1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ internal object PodcastindexParser : NamespaceParser() {
val lockedBuilder = ifCanBeParsed {
toLockedBuilder(builder.createLockedBuilder())
} ?: return
builder.podcastPodcastindexBuilder.lockedBuilder(lockedBuilder)
builder.podcastindexBuilder.lockedBuilder(lockedBuilder)
}
"funding" -> {
val fundingBuilder = ifCanBeParsed {
toFundingBuilder(builder.createFundingBuilder())
} ?: return
builder.podcastPodcastindexBuilder.addFundingBuilder(fundingBuilder)
builder.podcastindexBuilder.addFundingBuilder(fundingBuilder)
}
"person" -> {
val personBuilder = ifCanBeParsed {
toPersonBuilder(builder.createPersonBuilder())
} ?: return
builder.podcastPodcastindexBuilder.addPersonBuilder(personBuilder)
builder.podcastindexBuilder.addPersonBuilder(personBuilder)
}
"location" -> {
val locationBuilder = ifCanBeParsed {
toLocationBuilder(builder.createLocationBuilder())
} ?: return
builder.podcastPodcastindexBuilder.locationBuilder(locationBuilder)
builder.podcastindexBuilder.locationBuilder(locationBuilder)
}
else -> pass
}
Expand Down
26 changes: 13 additions & 13 deletions src/test/kotlin/dev/stalla/Assertions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,44 +158,44 @@ internal fun Assert<MediaType>.equalToString(expected: String) = given { mediaTy

/** Asserts that [MediaType.toString] matches the expected value. */
internal fun Assert<MediaType>.equalToString(expected: MediaType) = given { mediaType ->
if (mediaType.match(expected)) return@given
if (mediaType.matches(expected)) return@given
expected(
"to be: '$expected' but was: '$mediaType'",
expected = expected,
actual = mediaType
)
}

/** Asserts that [MediaType.match] matches the expected value. */
/** Asserts that [MediaType.matches] matches the expected value. */
internal fun Assert<MediaType>.matchPattern(expected: String) = given { mediaType ->
if (mediaType.match(expected)) return@given
if (mediaType.matches(expected)) return@given
expected(
"to have the string form: '$expected' but was: '$mediaType'",
expected = expected,
actual = mediaType.toString()
)
}

/** Asserts that [MediaType.match] matches the expected value. */
/** Asserts that [MediaType.matches] matches the expected value. */
internal fun Assert<MediaType>.matchPattern(expected: MediaType) = given { mediaType ->
if (mediaType.match(expected)) return@given
if (mediaType.matches(expected)) return@given
expected(
"to be: '$expected' but was: '$mediaType'",
expected = expected,
actual = mediaType
)
}

/** Asserts that this matches [expected] symmetrically using [MediaType.match]. */
/** Asserts that this matches [expected] symmetrically using [MediaType.matches]. */
internal fun Assert<MediaType>.matchesSymmetrically(expected: MediaType?) = given { mediaType ->
if (!mediaType.match(expected)) {
if (!mediaType.matches(expected)) {
expected(
"to match symmetrically, but the direction: '$mediaType' match '$expected' failed",
expected = true,
actual = false
)
}
if (!expected.match(mediaType)) {
if (!expected.matches(mediaType)) {
expected(
"to match symmetrically, but the direction: '$expected' match '$mediaType' failed",
expected = true,
Expand All @@ -204,16 +204,16 @@ internal fun Assert<MediaType>.matchesSymmetrically(expected: MediaType?) = give
}
}

/** Asserts that this does not match [expected] symmetrically using [MediaType.match]. */
/** Asserts that this does not match [expected] symmetrically using [MediaType.matches]. */
internal fun Assert<MediaType>.doesNotMatchSymmetrically(expected: MediaType?) = given { mediaType ->
if (mediaType.match(expected)) {
if (mediaType.matches(expected)) {
expected(
"to not match symmetrically, but the direction: '$mediaType' match '$expected' succeeded",
expected = false,
actual = true
)
}
if (expected != null && expected.match(mediaType)) {
if (expected != null && expected.matches(mediaType)) {
expected(
"to not match symmetrically, but the direction: '$expected' match '$mediaType' succeeded",
expected = false,
Expand All @@ -222,9 +222,9 @@ internal fun Assert<MediaType>.doesNotMatchSymmetrically(expected: MediaType?) =
}
}

/** Asserts that [GeographicLocation.match] matches the expected value. */
/** Asserts that [GeographicLocation.matches] matches the expected value. */
internal fun Assert<GeographicLocation>.matchPattern(expected: GeographicLocation) = given { geoLocation ->
if (geoLocation.match(expected)) return@given
if (geoLocation.matches(expected)) return@given
expected(
"to be: '$expected', but was: '$geoLocation'",
expected = expected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ internal class FakePodcastBuilder : FakeBuilder<Podcast>(), ProvidingPodcastBuil

override val googleplayBuilder: FakePodcastGoogleplayBuilder = FakePodcastGoogleplayBuilder()

override val podcastPodcastindexBuilder: FakePodcastPodcastindexBuilder = FakePodcastPodcastindexBuilder()
override val podcastindexBuilder: FakePodcastPodcastindexBuilder = FakePodcastPodcastindexBuilder()

override val podcastPodcastindexBuilder: FakePodcastPodcastindexBuilder by this::podcastindexBuilder

override fun title(title: String): PodcastBuilder = apply { this.titleValue = title }

Expand Down Expand Up @@ -114,7 +116,9 @@ internal class FakePodcastBuilder : FakeBuilder<Podcast>(), ProvidingPodcastBuil

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is FakePodcastBuilder) return false
if (javaClass != other?.javaClass) return false

other as FakePodcastBuilder

if (titleValue != other.titleValue) return false
if (linkValue != other.linkValue) return false
Expand All @@ -136,6 +140,7 @@ internal class FakePodcastBuilder : FakeBuilder<Podcast>(), ProvidingPodcastBuil
if (fyydBuilder != other.fyydBuilder) return false
if (feedpressBuilder != other.feedpressBuilder) return false
if (googleplayBuilder != other.googleplayBuilder) return false
if (podcastindexBuilder != other.podcastindexBuilder) return false
if (podcastPodcastindexBuilder != other.podcastPodcastindexBuilder) return false

return true
Expand All @@ -153,7 +158,7 @@ internal class FakePodcastBuilder : FakeBuilder<Podcast>(), ProvidingPodcastBuil
result = 31 * result + (docs?.hashCode() ?: 0)
result = 31 * result + (managingEditor?.hashCode() ?: 0)
result = 31 * result + (webMaster?.hashCode() ?: 0)
result = 31 * result + (ttl?.hashCode() ?: 0)
result = 31 * result + (ttl ?: 0)
result = 31 * result + (imageBuilder?.hashCode() ?: 0)
result = 31 * result + episodeBuilders.hashCode()
result = 31 * result + categoryBuilders.hashCode()
Expand All @@ -162,14 +167,16 @@ internal class FakePodcastBuilder : FakeBuilder<Podcast>(), ProvidingPodcastBuil
result = 31 * result + fyydBuilder.hashCode()
result = 31 * result + feedpressBuilder.hashCode()
result = 31 * result + googleplayBuilder.hashCode()
result = 31 * result + podcastindexBuilder.hashCode()
result = 31 * result + podcastPodcastindexBuilder.hashCode()
return result
}

override fun toString() =
"FakePodcastBuilder(titleValue=$titleValue, linkValue=$linkValue, descriptionValue=$descriptionValue, languageValue=$languageValue, " +
"pubDate=$pubDate, lastBuildDate=$lastBuildDate, generator=$generator, copyright=$copyright, docs=$docs, " +
"managingEditor=$managingEditor, webMaster=$webMaster, ttl=$ttl, imageBuilder=$imageBuilder, episodeBuilders=$episodeBuilders, " +
"categoryBuilders=$categoryBuilders, iTunesBuilder=$itunesBuilder, atomBuilder=$atomBuilder, fyydBuilder=$fyydBuilder, " +
"feedpressBuilder=$feedpressBuilder, googlePlayBuilder=$googleplayBuilder, podcastBuilder=$podcastPodcastindexBuilder)"
override fun toString(): String =
"FakePodcastBuilder(titleValue=$titleValue, linkValue=$linkValue, descriptionValue=$descriptionValue, " +
"languageValue=$languageValue, pubDate=$pubDate, lastBuildDate=$lastBuildDate, generator=$generator, copyright=$copyright, " +
"docs=$docs, managingEditor=$managingEditor, webMaster=$webMaster, ttl=$ttl, imageBuilder=$imageBuilder, " +
"episodeBuilders=$episodeBuilders, categoryBuilders=$categoryBuilders, itunesBuilder=$itunesBuilder, atomBuilder=$atomBuilder, " +
"fyydBuilder=$fyydBuilder, feedpressBuilder=$feedpressBuilder, googleplayBuilder=$googleplayBuilder, " +
"podcastindexBuilder=$podcastindexBuilder, podcastPodcastindexBuilder=$podcastPodcastindexBuilder)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ internal class ValidatingPodcastBuilderTest {
feedpressBuilder.newsletterId("feedpress newsletterId")
fyydBuilder.verify("fyyd verify")
googleplayBuilder.description("play description")
podcastPodcastindexBuilder.lockedBuilder(expectedLockedBuilder)
podcastindexBuilder.lockedBuilder(expectedLockedBuilder)
}

assertAll {
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/dev/stalla/model/MediaTypeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ internal class MediaTypeTest {

@Test
fun `should match a predefined instance from a string pattern`() {
assertThat(MediaType.AAC_AUDIO.match("audio/aac")).isTrue()
assertThat(MediaType.AAC_AUDIO.matches("audio/aac")).isTrue()
}

@Test
fun `should match a predefined instance with a wildcard subtype`() {
assertThat(MediaType.AAC_AUDIO.match("audio/*")).isTrue()
assertThat(MediaType.AAC_AUDIO.matches("audio/*")).isTrue()
}

@Test
Expand Down

0 comments on commit 7f88528

Please sign in to comment.