mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-06-05 18:13:05 +03:00
Convert Playlist domain entity to kotlin.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
6d6380ca96
commit
5265e58d47
@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of Subsonic.
|
|
||||||
|
|
||||||
Subsonic is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Subsonic is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Copyright 2009 (C) Sindre Mehus
|
|
||||||
*/
|
|
||||||
package org.moire.ultrasonic.domain;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Sindre Mehus
|
|
||||||
*/
|
|
||||||
public class Playlist implements Serializable
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -4160515427075433798L;
|
|
||||||
private String id;
|
|
||||||
private String name;
|
|
||||||
private String owner;
|
|
||||||
private String comment;
|
|
||||||
private String songCount;
|
|
||||||
private String created;
|
|
||||||
private Boolean pub;
|
|
||||||
|
|
||||||
public Playlist(String id, String name)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Playlist(String id, String name, String owner, String comment, String songCount, String created, String pub)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.owner = (owner == null) ? "" : owner;
|
|
||||||
this.comment = (comment == null) ? "" : comment;
|
|
||||||
this.songCount = (songCount == null) ? "" : songCount;
|
|
||||||
this.created = (created == null) ? "" : created;
|
|
||||||
this.pub = (pub == null) ? null : ("true".equals(pub));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOwner()
|
|
||||||
{
|
|
||||||
return this.owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOwner(String owner)
|
|
||||||
{
|
|
||||||
this.owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComment()
|
|
||||||
{
|
|
||||||
return this.comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComment(String comment)
|
|
||||||
{
|
|
||||||
this.comment = comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSongCount()
|
|
||||||
{
|
|
||||||
return this.songCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSongCount(String songCount)
|
|
||||||
{
|
|
||||||
this.songCount = songCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreated()
|
|
||||||
{
|
|
||||||
return this.created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(String created)
|
|
||||||
{
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getPublic()
|
|
||||||
{
|
|
||||||
return this.pub;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublic(Boolean pub)
|
|
||||||
{
|
|
||||||
this.pub = pub;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Playlist{" +
|
|
||||||
"id='" + id + '\'' +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
", owner='" + owner + '\'' +
|
|
||||||
", comment='" + comment + '\'' +
|
|
||||||
", songCount='" + songCount + '\'' +
|
|
||||||
", created='" + created + '\'' +
|
|
||||||
", pub=" + pub +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
Playlist playlist = (Playlist) o;
|
|
||||||
|
|
||||||
if (id != null ? !id.equals(playlist.id) : playlist.id != null) return false;
|
|
||||||
if (name != null ? !name.equals(playlist.name) : playlist.name != null) return false;
|
|
||||||
if (owner != null ? !owner.equals(playlist.owner) : playlist.owner != null) return false;
|
|
||||||
if (comment != null ? !comment.equals(playlist.comment) : playlist.comment != null)
|
|
||||||
return false;
|
|
||||||
if (songCount != null ? !songCount.equals(playlist.songCount) : playlist.songCount != null)
|
|
||||||
return false;
|
|
||||||
if (created != null ? !created.equals(playlist.created) : playlist.created != null)
|
|
||||||
return false;
|
|
||||||
return pub != null ? pub.equals(playlist.pub) : playlist.pub == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = id != null ? id.hashCode() : 0;
|
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
|
||||||
result = 31 * result + (owner != null ? owner.hashCode() : 0);
|
|
||||||
result = 31 * result + (comment != null ? comment.hashCode() : 0);
|
|
||||||
result = 31 * result + (songCount != null ? songCount.hashCode() : 0);
|
|
||||||
result = 31 * result + (created != null ? created.hashCode() : 0);
|
|
||||||
result = 31 * result + (pub != null ? pub.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,7 @@ fun APIPlaylist.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory(
|
|||||||
|
|
||||||
fun APIPlaylist.toDomainEntity(): Playlist = Playlist(this.id, this.name, this.owner,
|
fun APIPlaylist.toDomainEntity(): Playlist = Playlist(this.id, this.name, this.owner,
|
||||||
this.comment, this.songCount.toString(),
|
this.comment, this.songCount.toString(),
|
||||||
this.created?.let { playlistDateFormat.format(it.time) },
|
this.created?.let { playlistDateFormat.format(it.time) } ?: "",
|
||||||
public.toString())
|
public)
|
||||||
|
|
||||||
fun List<APIPlaylist>.toDomainEntitiesList(): List<Playlist> = this.map { it.toDomainEntity() }
|
fun List<APIPlaylist>.toDomainEntitiesList(): List<Playlist> = this.map { it.toDomainEntity() }
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.moire.ultrasonic.domain
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
data class Playlist @JvmOverloads constructor(
|
||||||
|
val id: String,
|
||||||
|
var name: String,
|
||||||
|
val owner: String = "",
|
||||||
|
val comment: String = "",
|
||||||
|
val songCount: String = "",
|
||||||
|
val created: String = "",
|
||||||
|
val public: Boolean? = null
|
||||||
|
) : Serializable {
|
||||||
|
companion object {
|
||||||
|
private const val serialVersionUID = -4160515427075433798L
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user