Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Googleplay Podcast explicit type #95

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# CHANGELOG

## v1.1.0 (under development)

* Add support for PodcastIndex namespace phase 2 tags
* Use `ExplicitType` for the Google Play `explicit` attribute at the `Podcast` level, too (see API changes table below)

### Notable API changes

All API changes are subject to deprecation, with automatic migrations provided. Deprecated properties will be removed entirely in a future release —
refer to the table below, and the properties themselves for the removal schedule.

The APIs that have been changed or deprecated since v1.0.0 are:

API that has changed | What has changed | Notes
--- | --- | ---
`MediaType.match(MediaType?)` | Renamed to `matches(MediaType?)` | Scheduled for removal in v2.0.0.
`MediaType.match(String)` | Renamed to `matches(String)` | Scheduled for removal in v2.0.0.
`PodcastBuilder.podcastPodcastindexBuilder` | Renamed to `podcastindexBuilder` | Scheduled for removal in v2.0.0.
`PodcastGoogleplay.explicit` | Renamed to `explicitType`, type changed to `ExplicitType` | The `explicit` property type is scheduled for removal in v2.0.0, and the `explicitType` property will be renamed to `explicit`.
`PodcastGoogleplay(..., explicit, ...)` | Replaced `explicit` parameter with `explicitType` | The `explicit`-based constructor type is scheduled for removal in v2.0.0.

## v1.0.0

* Refactor model structure (no inner classes) into separate classes and packages
Expand All @@ -12,7 +32,7 @@
* Adds feed writing support
* Adds additional elements for RSS and iTunes namespace
* Adds support for Podcastindex namespace
* Adds a huge amount of unit tests
* Adds a huge number of unit tests
* Adds builder factory methods to model companion objects
* Changes to java.time representation

Expand All @@ -35,7 +55,8 @@
## v0.5.1

* Fixes the URI for the Podlove Simple Chapter namespace.
* Adds [Travis-CI](https://travis-ci.org/mpgirro/wien), [Codacy](https://app.codacy.com/project/mpgirro/wien), and [CodeCov](https://codecov.io/gh/mpgirro/wien) setup.
* Adds [Travis-CI](https://travis-ci.org/mpgirro/wien), [Codacy](https://app.codacy.com/project/mpgirro/wien),
and [CodeCov](https://codecov.io/gh/mpgirro/wien) setup.

## v0.5.0

Expand Down
11 changes: 8 additions & 3 deletions api/stalla.api
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,15 @@ public abstract interface class dev/stalla/builder/podcast/PodcastGoogleplayBuil
public abstract fun description (Ljava/lang/String;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public abstract fun email (Ljava/lang/String;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public abstract fun explicit (Ljava/lang/Boolean;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public abstract fun explicitType (Ldev/stalla/model/googleplay/ExplicitType;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public abstract fun imageBuilder (Ldev/stalla/builder/HrefOnlyImageBuilder;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public abstract fun newFeedUrl (Ljava/lang/String;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
}

public final class dev/stalla/builder/podcast/PodcastGoogleplayBuilder$DefaultImpls {
public static fun addAllCategories (Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;Ljava/util/List;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public static fun applyFrom (Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;Ldev/stalla/model/googleplay/PodcastGoogleplay;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public static fun explicit (Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;Ljava/lang/Boolean;)Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
}

public abstract interface class dev/stalla/builder/podcast/PodcastItunesBuilder : dev/stalla/builder/Builder {
Expand Down Expand Up @@ -1035,26 +1037,29 @@ public final class dev/stalla/model/googleplay/GoogleplayCategory$Factory : dev/

public final class dev/stalla/model/googleplay/PodcastGoogleplay {
public static final field Factory Ldev/stalla/model/googleplay/PodcastGoogleplay$Factory;
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ldev/stalla/model/googleplay/ExplicitType;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ldev/stalla/model/googleplay/ExplicitType;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/Boolean;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/Boolean;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public static fun builder ()Ldev/stalla/builder/podcast/PodcastGoogleplayBuilder;
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/util/List;
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()Ljava/lang/Boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first binary incompatible change

public final fun component5 ()Ldev/stalla/model/googleplay/ExplicitType;
public final fun component6 ()Z
public final fun component7 ()Ldev/stalla/model/HrefOnlyImage;
public final fun component8 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/Boolean;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;)Ldev/stalla/model/googleplay/PodcastGoogleplay;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the other binary incompatible change

public static synthetic fun copy$default (Ldev/stalla/model/googleplay/PodcastGoogleplay;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/Boolean;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;ILjava/lang/Object;)Ldev/stalla/model/googleplay/PodcastGoogleplay;
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ldev/stalla/model/googleplay/ExplicitType;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;)Ldev/stalla/model/googleplay/PodcastGoogleplay;
public static synthetic fun copy$default (Ldev/stalla/model/googleplay/PodcastGoogleplay;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ldev/stalla/model/googleplay/ExplicitType;ZLdev/stalla/model/HrefOnlyImage;Ljava/lang/String;ILjava/lang/Object;)Ldev/stalla/model/googleplay/PodcastGoogleplay;
public fun equals (Ljava/lang/Object;)Z
public final fun getAuthor ()Ljava/lang/String;
public final fun getBlock ()Z
public final fun getCategories ()Ljava/util/List;
public final fun getDescription ()Ljava/lang/String;
public final fun getEmail ()Ljava/lang/String;
public final fun getExplicit ()Ljava/lang/Boolean;
public final fun getExplicitType ()Ldev/stalla/model/googleplay/ExplicitType;
public final fun getImage ()Ldev/stalla/model/HrefOnlyImage;
public final fun getNewFeedUrl ()Ljava/lang/String;
public fun hashCode ()I
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface PodcastBuilder : Builder<Podcast> {

/** The builder for data from the Podcastindex namespace. */
@Deprecated(
message = "This property is scheduled for removal in v2.0.0",
message = "This property is scheduled for removal in v2.0.0.",
replaceWith = ReplaceWith("podcastindexBuilder")
)
public val podcastPodcastindexBuilder: PodcastPodcastindexBuilder
Expand Down
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.builder.HrefOnlyImageBuilder
import dev.stalla.model.HrefOnlyImage
import dev.stalla.model.googleplay.ExplicitType
import dev.stalla.model.googleplay.GoogleplayCategory
import dev.stalla.model.googleplay.PodcastGoogleplay
import dev.stalla.util.whenNotNull
Expand Down Expand Up @@ -31,7 +32,20 @@ public interface PodcastGoogleplayBuilder : Builder<PodcastGoogleplay> {
public fun description(description: String?): PodcastGoogleplayBuilder

/** Set the explicit flag value. */
public fun explicit(explicit: Boolean?): PodcastGoogleplayBuilder
@Deprecated(
message = "Use explicitType(ExplicitType?) instead. Scheduled for removal in v2.0.0.",
replaceWith = ReplaceWith("explicitType()")
)
public fun explicit(explicit: Boolean?): PodcastGoogleplayBuilder = explicitType(
when (explicit) {
true -> ExplicitType.YES
false -> ExplicitType.NO
else -> null
}
)

/** Set the explicit flag value. */
public fun explicitType(explicitType: ExplicitType?): PodcastGoogleplayBuilder

/** Set the block flag value. */
public fun block(block: Boolean): PodcastGoogleplayBuilder
Expand All @@ -48,7 +62,7 @@ public interface PodcastGoogleplayBuilder : Builder<PodcastGoogleplay> {
email(googleplay.email)
addAllCategories(googleplay.categories)
description(googleplay.description)
explicit(googleplay.explicit)
explicitType(googleplay.explicitType)
block(googleplay.block)
imageBuilder(HrefOnlyImage.builder().applyFrom(googleplay.image))
newFeedUrl(googleplay.newFeedUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.stalla.builder.validating.podcast

import dev.stalla.builder.HrefOnlyImageBuilder
import dev.stalla.builder.podcast.PodcastGoogleplayBuilder
import dev.stalla.model.googleplay.ExplicitType
import dev.stalla.model.googleplay.GoogleplayCategory
import dev.stalla.model.googleplay.PodcastGoogleplay
import dev.stalla.util.InternalAPI
Expand All @@ -15,7 +16,7 @@ internal class ValidatingPodcastGoogleplayBuilder : PodcastGoogleplayBuilder {
private var email: String? = null
private var categories: MutableList<GoogleplayCategory> = mutableListOf()
private var description: String? = null
private var explicit: Boolean? = null
private var explicitType: ExplicitType? = null
private var block: Boolean = false
private var imageBuilder: HrefOnlyImageBuilder? = null
private var newFeedUrl: String? = null
Expand All @@ -29,7 +30,7 @@ internal class ValidatingPodcastGoogleplayBuilder : PodcastGoogleplayBuilder {

override fun description(description: String?): PodcastGoogleplayBuilder = apply { this.description = description }

override fun explicit(explicit: Boolean?): PodcastGoogleplayBuilder = apply { this.explicit = explicit }
override fun explicitType(explicitType: ExplicitType?): PodcastGoogleplayBuilder = apply { this.explicitType = explicitType }

override fun block(block: Boolean): PodcastGoogleplayBuilder = apply { this.block = block }

Expand All @@ -41,7 +42,7 @@ internal class ValidatingPodcastGoogleplayBuilder : PodcastGoogleplayBuilder {
override val hasEnoughDataToBuild: Boolean
get() {
if (block) return true
if (anyNotNull(author, email, description, explicit, newFeedUrl)) return true
if (anyNotNull(author, email, description, explicitType, newFeedUrl)) return true
if (imageBuilder?.hasEnoughDataToBuild == true) return true
return categories.isNotEmpty()
}
Expand All @@ -56,7 +57,7 @@ internal class ValidatingPodcastGoogleplayBuilder : PodcastGoogleplayBuilder {
email = email,
categories = categories.asUnmodifiable(),
description = description,
explicit = explicit,
explicitType = explicitType,
block = block,
image = imageBuilder?.build(),
newFeedUrl = newFeedUrl
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/dev/stalla/model/MediaType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public open class MediaType private constructor(
* 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",
message = "This method is scheduled for removal in v2.0.0.",
replaceWith = ReplaceWith("matches")
)
public fun match(pattern: MediaType?): Boolean = matches(pattern)
Expand All @@ -127,7 +127,7 @@ public open class MediaType private constructor(
* into account placeholder symbols `*` and parameters.
*/
@Deprecated(
message = "This method is scheduled for removal in v2.0.0",
message = "This method is scheduled for removal in v2.0.0.",
replaceWith = ReplaceWith("matches")
)
public fun match(pattern: String): Boolean = matches(pattern)
Expand Down Expand Up @@ -216,6 +216,7 @@ public open class MediaType private constructor(
}

/** Gets an instance of [MediaType] from a raw value. Exposes several predefined media type constants. */
@Suppress("unused") // These are commonly used MediaTypes, for users' convenience.
public companion object Factory : TypeFactory<MediaType> {

/**
Expand Down
31 changes: 29 additions & 2 deletions src/main/kotlin/dev/stalla/model/googleplay/PodcastGoogleplay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import dev.stalla.model.HrefOnlyImage
* @property email The `<googleplay:email>` element text content.
* @property categories The list of `<googleplay:category>` element text contents as [GoogleplayCategory].
* @property description The `<googleplay:description>` element text content.
* @property explicit The logical value of the `<googleplay:explicit>` element text content.
* @property explicitType The logical value of the `<googleplay:explicit>` element text content. Will be renamed to `explicit` in v2.0.0.
* @property block The logical value of the `<googleplay:block>` element text content.
* @property image The data from the `<googleplay:image>` element as an [HrefOnlyImage].
* @property newFeedUrl The `<googleplay:newFeedUrl>` element text content.
Expand All @@ -31,12 +31,39 @@ public data class PodcastGoogleplay(
val email: String? = null,
val categories: List<GoogleplayCategory>,
val description: String? = null,
val explicit: Boolean? = null,
val explicitType: ExplicitType? = null,
val block: Boolean,
val image: HrefOnlyImage? = null,
val newFeedUrl: String? = null
) {

@Deprecated(
message = "Use the new constructor taking explicitType instead. This constructor is scheduled for removal in v2.0.0.",
replaceWith = ReplaceWith(
"PodcastGoogleplay(author, email, categories, description, if (explicit) ExplicitType.YES else ExplicitType.NO, block, image, " +
"newFeedUrl)",
"dev.stalla.model.googleplay.ExplicitType"
)
)
public constructor(
author: String? = null,
email: String? = null,
categories: List<GoogleplayCategory>,
description: String? = null,
explicit: Boolean? = null,
block: Boolean,
image: HrefOnlyImage? = null,
newFeedUrl: String? = null
) : this(author, email, categories, description, explicit?.let { if (it) ExplicitType.YES else ExplicitType.NO }, block, image, newFeedUrl)

/** The logical value of the `<googleplay:explicit>` element text content. */
@Deprecated(
message = "The explicit property is deprecated. Please migrate to the explicitType property, which will be renamed to 'explicit' once " +
"this property is removed. This property is scheduled for removal in v2.0.0.",
replaceWith = ReplaceWith("explicitType == ExplicitType.YES", "dev.stalla.model.googleplay.ExplicitType")
)
val explicit: Boolean? = explicitType?.let { it == ExplicitType.YES }

/** Provides a builder for the [PodcastGoogleplay] class. */
public companion object Factory : BuilderFactory<PodcastGoogleplay, PodcastGoogleplayBuilder> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import dev.stalla.dom.appendElement
import dev.stalla.dom.appendGoogleplayCategoryElements
import dev.stalla.dom.appendHrefOnlyImageElement
import dev.stalla.dom.appendYesElementIfTrue
import dev.stalla.dom.appendYesNoElement
import dev.stalla.model.Episode
import dev.stalla.model.Podcast
import dev.stalla.util.FeedNamespace
Expand All @@ -30,8 +29,8 @@ internal object GoogleplayWriter : NamespaceWriter() {
appendElement("email", namespace) { textContent = play.email.trim() }
}

if (play.explicit != null) {
appendYesNoElement("explicit", play.explicit, namespace)
if (play.explicitType != null) {
appendElement("explicit", namespace) { textContent = play.explicitType.type.trim() }
}

if (play.newFeedUrl.isNeitherNullNorBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.stalla.builder.fake.podcast
import dev.stalla.builder.HrefOnlyImageBuilder
import dev.stalla.builder.fake.FakeBuilder
import dev.stalla.builder.podcast.PodcastGoogleplayBuilder
import dev.stalla.model.googleplay.ExplicitType
import dev.stalla.model.googleplay.GoogleplayCategory
import dev.stalla.model.googleplay.PodcastGoogleplay

Expand All @@ -12,7 +13,7 @@ internal class FakePodcastGoogleplayBuilder : FakeBuilder<PodcastGoogleplay>(),
var email: String? = null
var categories: MutableList<GoogleplayCategory> = mutableListOf()
var description: String? = null
var explicit: Boolean? = null
var explicitType: ExplicitType? = null
var block: Boolean? = null
var imageBuilder: HrefOnlyImageBuilder? = null
var newFeedUrl: String? = null
Expand All @@ -27,7 +28,7 @@ internal class FakePodcastGoogleplayBuilder : FakeBuilder<PodcastGoogleplay>(),

override fun description(description: String?): PodcastGoogleplayBuilder = apply { this.description = description }

override fun explicit(explicit: Boolean?): PodcastGoogleplayBuilder = apply { this.explicit = explicit }
override fun explicitType(explicitType: ExplicitType?): PodcastGoogleplayBuilder = apply { this.explicitType = explicitType }

override fun block(block: Boolean): PodcastGoogleplayBuilder = apply { this.block = block }

Expand All @@ -43,7 +44,7 @@ internal class FakePodcastGoogleplayBuilder : FakeBuilder<PodcastGoogleplay>(),
if (email != other.email) return false
if (categories != other.categories) return false
if (description != other.description) return false
if (explicit != other.explicit) return false
if (explicitType != other.explicitType) return false
if (block != other.block) return false
if (imageBuilder != other.imageBuilder) return false
if (newFeedUrl != other.newFeedUrl) return false
Expand All @@ -56,7 +57,7 @@ internal class FakePodcastGoogleplayBuilder : FakeBuilder<PodcastGoogleplay>(),
result = 31 * result + (email?.hashCode() ?: 0)
result = 31 * result + categories.hashCode()
result = 31 * result + (description?.hashCode() ?: 0)
result = 31 * result + (explicit?.hashCode() ?: 0)
result = 31 * result + (explicitType?.hashCode() ?: 0)
result = 31 * result + (block?.hashCode() ?: 0)
result = 31 * result + (imageBuilder?.hashCode() ?: 0)
result = 31 * result + (newFeedUrl?.hashCode() ?: 0)
Expand All @@ -65,6 +66,6 @@ internal class FakePodcastGoogleplayBuilder : FakeBuilder<PodcastGoogleplay>(),

override fun toString(): String {
return "FakePodcastGoogleplayBuilder(author=$author, email=$email, categories=$categories, description=$description, " +
"explicit=$explicit, block=$block, imageBuilder=$imageBuilder, newFeedUrl=$newFeedUrl)"
"explicit=$explicitType, block=$block, imageBuilder=$imageBuilder, newFeedUrl=$newFeedUrl)"
}
}
Loading