mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-16 17:22:23 +03:00
Convert Artist domain entity to kotlin.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
3e3d39e2cd
commit
47d5a4dba1
@ -1,132 +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 Artist implements Serializable
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5790532593784846982L;
|
||||
private String id;
|
||||
private String name;
|
||||
private String index;
|
||||
private String coverArt;
|
||||
private Long albumCount;
|
||||
private int closeness;
|
||||
|
||||
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 getIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(String index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getCoverArt()
|
||||
{
|
||||
return coverArt;
|
||||
}
|
||||
|
||||
public void setCoverArt(String coverArt)
|
||||
{
|
||||
this.coverArt = coverArt;
|
||||
}
|
||||
|
||||
public long getAlbumCount()
|
||||
{
|
||||
return albumCount;
|
||||
}
|
||||
|
||||
public void setAlbumCount(Long albumCount)
|
||||
{
|
||||
this.albumCount = albumCount;
|
||||
}
|
||||
|
||||
public int getCloseness()
|
||||
{
|
||||
return closeness;
|
||||
}
|
||||
|
||||
public void setCloseness(int closeness)
|
||||
{
|
||||
this.closeness = closeness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Artist artist = (Artist) o;
|
||||
|
||||
if (closeness != artist.closeness) return false;
|
||||
if (id != null ? !id.equals(artist.id) : artist.id != null) return false;
|
||||
if (name != null ? !name.equals(artist.name) : artist.name != null) return false;
|
||||
if (index != null ? !index.equals(artist.index) : artist.index != null) return false;
|
||||
if (coverArt != null ? !coverArt.equals(artist.coverArt) : artist.coverArt != null)
|
||||
return false;
|
||||
return albumCount != null ? albumCount.equals(artist.albumCount) : artist.albumCount == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + (index != null ? index.hashCode() : 0);
|
||||
result = 31 * result + (coverArt != null ? coverArt.hashCode() : 0);
|
||||
result = 31 * result + (albumCount != null ? albumCount.hashCode() : 0);
|
||||
result = 31 * result + closeness;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -5,10 +5,10 @@ package org.moire.ultrasonic.domain
|
||||
|
||||
import org.moire.ultrasonic.api.subsonic.models.Artist as APIArtist
|
||||
|
||||
fun APIArtist.toDomainEntity(): Artist = Artist().apply {
|
||||
id = this@toDomainEntity.id
|
||||
fun APIArtist.toDomainEntity(): Artist = Artist(
|
||||
id = this@toDomainEntity.id,
|
||||
name = this@toDomainEntity.name
|
||||
}
|
||||
)
|
||||
|
||||
fun APIArtist.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
||||
name = this@toMusicDirectoryDomainEntity.name
|
||||
|
@ -0,0 +1,16 @@
|
||||
package org.moire.ultrasonic.domain
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class Artist(
|
||||
var id: String? = null,
|
||||
var name: String? = null,
|
||||
var index: String? = null,
|
||||
var coverArt: String? = null,
|
||||
var albumCount: Long? = null,
|
||||
var closeness: Int = 0
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = -5790532593784846982L
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ class APIArtistConverterTest {
|
||||
val convertedEntity = entity.toDomainEntity()
|
||||
|
||||
with(convertedEntity) {
|
||||
id `should equal to` entity.id
|
||||
name `should equal to` entity.name
|
||||
id `should equal` entity.id
|
||||
name `should equal` entity.name
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user