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

Migrate Java files to Kotlin #49

Merged
merged 5 commits into from
Sep 3, 2024
Merged

Migrate Java files to Kotlin #49

merged 5 commits into from
Sep 3, 2024

Conversation

MGaetan89
Copy link
Member

@MGaetan89 MGaetan89 commented Aug 30, 2024

This PR migrates the remaining Java files to Kotlin. Each file is migrated in a dedicated commit.

To ensure that this doesn't break usages from either Java or Kotlin clients, I've created the following simple classes. They do not test the behavior, only that the API of each class remained the same.

package ch.srg.dataProvider.integrationlayer

import ch.srg.dataProvider.integrationlayer.data.remote.Quality
import ch.srg.dataProvider.integrationlayer.data.remote.Resource
import ch.srg.dataProvider.integrationlayer.data.remote.StreamingMethod
import ch.srg.dataProvider.integrationlayer.request.IlHost
import ch.srg.dataProvider.integrationlayer.utils.IlUrn
import ch.srg.dataProvider.integrationlayer.utils.StreamComparator

class KotlinUsages {
    fun ilHost() {
        IlHost.PROD
        IlHost.TEST
        IlHost.STAGE
        IlHost.MMF
        IlHost.MMF_PUBLIC
        IlHost.PROD_SAM
        IlHost.TEST_SAM
        IlHost.STAGE_SAM

        val ilHost = IlHost("custom-host", "my.il.host.com")
        ilHost.value
        ilHost.name
        ilHost.hostUri
    }

    fun streamComparator() {
        StreamComparator.SCORE_NOT_SUPPORTED

        val resource1 = Resource(url = "https://www.rts.ch/", quality = Quality.HD, streamingMethod = StreamingMethod.HLS)
        val resource2 = Resource(url = "https://www.srgssr.ch/", quality = Quality.SD, streamingMethod = StreamingMethod.DASH)
        val streamComparator = StreamComparator(emptyList(), emptyList(), emptyList(), false)
        streamComparator.compare(resource1, resource2)
        streamComparator.score(resource1)
    }

    fun ilUrn() {
        IlUrn.ASSET_VIDEO
        IlUrn.ASSET_VIDEO_SET
        IlUrn.ASSET_AUDIO
        IlUrn.ASSET_SHOW
        IlUrn.ASSET_GROUP

        IlUrn.isUrn("")
        IlUrn.format("", "", "")
        IlUrn.isAudio("")
        IlUrn.isVideo("")
        IlUrn.getId("")
        IlUrn.getAssetType("")

        val ilUrn1 = IlUrn("")
        val ilUrn2 = IlUrn("", "", "")

        ilUrn1.bu
        ilUrn1.assetType
        ilUrn1.id
        ilUrn1.isAudio
        ilUrn1.isVideo
        ilUrn1.isShow
        ilUrn1.equalsToString("")
    }
}
package ch.srg.dataProvider.integrationlayer;

import java.util.Collections;

import ch.srg.dataProvider.integrationlayer.data.remote.Resource;
import ch.srg.dataProvider.integrationlayer.request.IlHost;
import ch.srg.dataProvider.integrationlayer.utils.IlUrn;
import ch.srg.dataProvider.integrationlayer.utils.StreamComparator;

public class JavaUsages {
    void ilHost() {
        var prod = IlHost.PROD;
        var test = IlHost.TEST;
        var stage = IlHost.STAGE;
        var mmf = IlHost.MMF;
        var mmfPublic = IlHost.MMF_PUBLIC;
        var prodSam = IlHost.PROD_SAM;
        var testSam = IlHost.TEST_SAM;
        var stageSam = IlHost.STAGE_SAM;

        var ilHost = new IlHost("custom-host", "my.il.host.com");
        ilHost.getValue();
        ilHost.getName();
        ilHost.getHostUri();
    }

    void streamComparator() {
        var scoreNotSupported = StreamComparator.SCORE_NOT_SUPPORTED;

        var resource1 = new Resource(); // This doesn't compile, but the goal is just to see if calls on `StreamComparator` are fine
        var resource2 = new Resource(); // This doesn't compile, but the goal is just to see if calls on `StreamComparator` are fine
        var streamComparator = new StreamComparator(Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false);
        streamComparator.compare(resource1, resource2);
        streamComparator.score(resource1);
    }

    void ilUrn() {
        var assetVideo = IlUrn.ASSET_VIDEO;
        var assetVideoSet = IlUrn.ASSET_VIDEO_SET;
        var assetAudio = IlUrn.ASSET_AUDIO;
        var assetShow = IlUrn.ASSET_SHOW;
        var assetGroup = IlUrn.ASSET_GROUP;

        IlUrn.isUrn("");
        IlUrn.format("", "", "");
        IlUrn.isAudio("");
        IlUrn.isVideo("");
        IlUrn.getId("");
        IlUrn.getAssetType("");

        var ilUrn1 = new IlUrn("");
        var ilUrn2 = new IlUrn("", "", "");

        ilUrn1.getBu();
        ilUrn1.getAssetType();
        ilUrn1.getId();
        ilUrn1.isAudio();
        ilUrn1.isVideo();
        ilUrn1.isShow();
        ilUrn1.equalsToString("");
    }
}

These should work the same way on the master branch and in this PR.

@MGaetan89 MGaetan89 self-assigned this Aug 30, 2024
@MGaetan89 MGaetan89 force-pushed the migrate_java_to_kotlin branch from a934411 to 6168db6 Compare August 30, 2024 13:42
@MGaetan89 MGaetan89 force-pushed the migrate_java_to_kotlin branch from 8ebb31b to 60b6944 Compare September 3, 2024 11:35
Copy link
Contributor

@StaehliJ StaehliJ left a comment

Choose a reason for hiding this comment

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

Sounds good

@StaehliJ StaehliJ added this pull request to the merge queue Sep 3, 2024
Merged via the queue into main with commit 86c404b Sep 3, 2024
5 checks passed
@StaehliJ StaehliJ deleted the migrate_java_to_kotlin branch September 3, 2024 13:09
github-merge-queue bot pushed a commit that referenced this pull request Dec 11, 2024
This PR bumps Data Provider version to 0.11.0.

## What's Changed

* Update GitHub Actions workflow by @MGaetan89 in
#44
* Update to Gradle 8.10 and fix deprecation warnings by @MGaetan89 in
#45
* Fix warnings in Java/Kotlin code by @MGaetan89 in
#46
* Update dependencies by @MGaetan89 in
#47
* Update demo app to display request response by @MGaetan89 in
#48
* Migrate Java files to Kotlin by @MGaetan89 in
#49
* Update dependencies by @MGaetan89 in
#53
* Bump androidx.lifecycle:lifecycle-runtime from 2.8.6 to 2.8.7 in the
androidx group by @dependabot in
#54
* Bump org.robolectric:robolectric from 4.13 to 4.14 by @dependabot in
#58
* Bump android-gradle-plugin from 8.7.1 to 8.7.2 by @dependabot in
#55
* Bump androidx.paging:paging-common from 3.3.2 to 3.3.4 in the androidx
group by @dependabot in
#57
* Update nexus repository url by @StaehliJ in
#59
* Bump org.robolectric:robolectric from 4.14 to 4.14.1 by @dependabot in
#60
* Add param `forceSAM=true` when targeting sam endpoint by @Loic-Dumas
in #56
* Bump kotlin from 2.0.21 to 2.1.0 by @dependabot in
#61
* Bump android-gradle-plugin from 8.7.2 to 8.7.3 by @dependabot in
#62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants