All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iheartradio.m3u8.data.MasterPlaylist Maven / Gradle / Ivy

The newest version!
package com.iheartradio.m3u8.data;

import java.util.List;
import java.util.Objects;

public class MasterPlaylist {
    private final List mPlaylists;
    private final List mIFramePlaylists;
    private final List mMediaData;
    private final List mUnknownTags;
    private final StartData mStartData;

    private MasterPlaylist(List playlists, List iFramePlaylists, List mediaData, List unknownTags, StartData startData) {
        mPlaylists = DataUtil.emptyOrUnmodifiable(playlists);
        mIFramePlaylists = DataUtil.emptyOrUnmodifiable(iFramePlaylists);
        mMediaData = DataUtil.emptyOrUnmodifiable(mediaData);
        mUnknownTags = DataUtil.emptyOrUnmodifiable(unknownTags);
        mStartData = startData;
    }

    public List getPlaylists() {
        return mPlaylists;
    }

    public List getIFramePlaylists() {
        return mIFramePlaylists;
    }

    public List getMediaData() {
        return mMediaData;
    }
   
    public boolean hasUnknownTags() {
        return mUnknownTags.size() > 0;
    }
    
    public List getUnknownTags() {
        return mUnknownTags;
    }

    public boolean hasStartData() {
        return mStartData != null;
    }

    public StartData getStartData() {
        return mStartData;
    }

    public Builder buildUpon() {
        return new Builder(mPlaylists, mIFramePlaylists, mMediaData, mUnknownTags);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(mMediaData, mPlaylists, mIFramePlaylists, mUnknownTags, mStartData);
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof MasterPlaylist)) {
            return false;
        }

        MasterPlaylist other = (MasterPlaylist) o;
        
        return Objects.equals(mMediaData, other.mMediaData) &&
               Objects.equals(mPlaylists, other.mPlaylists) &&
               Objects.equals(mIFramePlaylists, other.mIFramePlaylists) &&
               Objects.equals(mUnknownTags, other.mUnknownTags) &&
               Objects.equals(mStartData, other.mStartData);
    }

    @Override
    public String toString() {
        return new StringBuilder()
                .append("(MasterPlaylist")
                .append(" mPlaylists=").append(mPlaylists.toString())
                .append(" mIFramePlaylists=").append(mIFramePlaylists.toString())
                .append(" mMediaData=").append(mMediaData.toString())
                .append(" mUnknownTags=").append(mUnknownTags.toString())
                .append(" mStartData=").append(mStartData.toString())
                .append(")")
                .toString();
    }

    public static class Builder {
        private List mPlaylists;
        private List mIFramePlaylists;
        private List mMediaData;
        private List mUnknownTags;
        private StartData mStartData;

        public Builder() {
        }

        private Builder(List playlists, List iFramePlaylists, List mediaData, List unknownTags) {
            mPlaylists = playlists;
            mIFramePlaylists = iFramePlaylists;
            mMediaData = mediaData;
            mUnknownTags = unknownTags;
        }

        private Builder(List playlists, List mediaData) {
            mPlaylists = playlists;
            mMediaData = mediaData;
        }

        public Builder withPlaylists(List playlists) {
            mPlaylists = playlists;
            return this;
        }

        public Builder withIFramePlaylists(List iFramePlaylists) {
            mIFramePlaylists = iFramePlaylists;
            return this;
        }

        public Builder withMediaData(List mediaData) {
            mMediaData = mediaData;
            return this;
        }
        
        public Builder withUnknownTags(List unknownTags) {
            mUnknownTags = unknownTags;
            return this;
        }

        public Builder withStartData(StartData startData) {
            mStartData = startData;
            return this;
        }

        public MasterPlaylist build() {
            return new MasterPlaylist(mPlaylists, mIFramePlaylists, mMediaData, mUnknownTags, mStartData);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy