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.

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
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