mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-16 17:22:23 +03:00
Convert Genre domain entity to kotlin.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
9ddd68f941
commit
ea5fd0d1be
@ -1,57 +0,0 @@
|
||||
package org.moire.ultrasonic.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Genre implements Serializable
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3943025175219134028L;
|
||||
private String name;
|
||||
private String index;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Genre genre = (Genre) o;
|
||||
|
||||
if (name != null ? !name.equals(genre.name) : genre.name != null) return false;
|
||||
return index != null ? index.equals(genre.index) : genre.index == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (index != null ? index.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
@ -4,9 +4,9 @@ package org.moire.ultrasonic.domain
|
||||
|
||||
import org.moire.ultrasonic.api.subsonic.models.Genre as APIGenre
|
||||
|
||||
fun APIGenre.toDomainEntity(): Genre = Genre().apply {
|
||||
name = this@toDomainEntity.name
|
||||
fun APIGenre.toDomainEntity(): Genre = Genre(
|
||||
name = this@toDomainEntity.name,
|
||||
index = this@toDomainEntity.name.substring(0, 1)
|
||||
}
|
||||
)
|
||||
|
||||
fun List<APIGenre>.toDomainEntityList(): List<Genre> = this.map { it.toDomainEntity() }
|
||||
|
@ -0,0 +1,12 @@
|
||||
package org.moire.ultrasonic.domain
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class Genre(
|
||||
val name: String,
|
||||
val index: String
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = -3943025175219134028L
|
||||
}
|
||||
}
|
@ -18,8 +18,8 @@ class ApiGenreConverterTest {
|
||||
val domainEntity = entity.toDomainEntity()
|
||||
|
||||
with(domainEntity) {
|
||||
name `should equal to` entity.name
|
||||
index `should equal to` "s"
|
||||
name `should equal` entity.name
|
||||
index `should equal` "s"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user