1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tv.dvr.data; 18 19 import android.text.TextUtils; 20 import java.util.Objects; 21 22 /** A plain java object which includes the season/episode number for the series recording. */ 23 public class SeasonEpisodeNumber { 24 public final long seriesRecordingId; 25 public final String seasonNumber; 26 public final String episodeNumber; 27 28 /** Creates a new Builder with the values set from an existing {@link ScheduledRecording}. */ SeasonEpisodeNumber(ScheduledRecording r)29 public SeasonEpisodeNumber(ScheduledRecording r) { 30 this(r.getSeriesRecordingId(), r.getSeasonNumber(), r.getEpisodeNumber()); 31 } 32 SeasonEpisodeNumber(long seriesRecordingId, String seasonNumber, String episodeNumber)33 public SeasonEpisodeNumber(long seriesRecordingId, String seasonNumber, String episodeNumber) { 34 this.seriesRecordingId = seriesRecordingId; 35 this.seasonNumber = seasonNumber; 36 this.episodeNumber = episodeNumber; 37 } 38 39 @Override equals(Object o)40 public boolean equals(Object o) { 41 if (this == o) { 42 return true; 43 } 44 if (!(o instanceof SeasonEpisodeNumber) 45 || TextUtils.isEmpty(seasonNumber) 46 || TextUtils.isEmpty(episodeNumber)) { 47 return false; 48 } 49 SeasonEpisodeNumber that = (SeasonEpisodeNumber) o; 50 return seriesRecordingId == that.seriesRecordingId 51 && Objects.equals(seasonNumber, that.seasonNumber) 52 && Objects.equals(episodeNumber, that.episodeNumber); 53 } 54 55 @Override hashCode()56 public int hashCode() { 57 return Objects.hash(seriesRecordingId, seasonNumber, episodeNumber); 58 } 59 60 @Override toString()61 public String toString() { 62 return "SeasonEpisodeNumber{" 63 + "seriesRecordingId=" 64 + seriesRecordingId 65 + ", seasonNumber='" 66 + seasonNumber 67 + ", episodeNumber=" 68 + episodeNumber 69 + '}'; 70 } 71 } 72