mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-06-13 22:12:10 +03:00
Convert Bookmark domain entity to kotlin.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
817122c16f
commit
3e3d39e2cd
@ -1,106 +0,0 @@
|
|||||||
package org.moire.ultrasonic.domain;
|
|
||||||
|
|
||||||
import org.moire.ultrasonic.domain.MusicDirectory.Entry;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class Bookmark implements Serializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 8988990025189807803L;
|
|
||||||
private int position;
|
|
||||||
private String username;
|
|
||||||
private String comment;
|
|
||||||
private Date created;
|
|
||||||
private Date changed;
|
|
||||||
private Entry entry;
|
|
||||||
|
|
||||||
public int getPosition()
|
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosition(int position)
|
|
||||||
{
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername()
|
|
||||||
{
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username)
|
|
||||||
{
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComment()
|
|
||||||
{
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComment(String comment)
|
|
||||||
{
|
|
||||||
this.comment = comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getChanged() {
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChanged(Date changed) {
|
|
||||||
this.changed = changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entry getEntry()
|
|
||||||
{
|
|
||||||
return this.entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntry(Entry entry)
|
|
||||||
{
|
|
||||||
this.entry = entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
Bookmark bookmark = (Bookmark) o;
|
|
||||||
|
|
||||||
if (position != bookmark.position) return false;
|
|
||||||
if (username != null ? !username.equals(bookmark.username) : bookmark.username != null)
|
|
||||||
return false;
|
|
||||||
if (comment != null ? !comment.equals(bookmark.comment) : bookmark.comment != null)
|
|
||||||
return false;
|
|
||||||
if (created != null ? !created.equals(bookmark.created) : bookmark.created != null)
|
|
||||||
return false;
|
|
||||||
if (changed != null ? !changed.equals(bookmark.changed) : bookmark.changed != null)
|
|
||||||
return false;
|
|
||||||
return entry != null ? entry.equals(bookmark.entry) : bookmark.entry == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = position;
|
|
||||||
result = 31 * result + (username != null ? username.hashCode() : 0);
|
|
||||||
result = 31 * result + (comment != null ? comment.hashCode() : 0);
|
|
||||||
result = 31 * result + (created != null ? created.hashCode() : 0);
|
|
||||||
result = 31 * result + (changed != null ? changed.hashCode() : 0);
|
|
||||||
result = 31 * result + (entry != null ? entry.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,13 +4,13 @@ package org.moire.ultrasonic.domain
|
|||||||
|
|
||||||
import org.moire.ultrasonic.api.subsonic.models.Bookmark as ApiBookmark
|
import org.moire.ultrasonic.api.subsonic.models.Bookmark as ApiBookmark
|
||||||
|
|
||||||
fun ApiBookmark.toDomainEntity(): Bookmark = Bookmark().apply {
|
fun ApiBookmark.toDomainEntity(): Bookmark = Bookmark(
|
||||||
position = this@toDomainEntity.position.toInt()
|
position = this@toDomainEntity.position.toInt(),
|
||||||
username = this@toDomainEntity.username
|
username = this@toDomainEntity.username,
|
||||||
comment = this@toDomainEntity.comment
|
comment = this@toDomainEntity.comment,
|
||||||
created = this@toDomainEntity.created?.time
|
created = this@toDomainEntity.created?.time,
|
||||||
changed = this@toDomainEntity.changed?.time
|
changed = this@toDomainEntity.changed?.time,
|
||||||
entry = this@toDomainEntity.entry.toDomainEntity()
|
entry = this@toDomainEntity.entry.toDomainEntity()
|
||||||
}
|
)
|
||||||
|
|
||||||
fun List<ApiBookmark>.toDomainEntitiesList(): List<Bookmark> = map { it.toDomainEntity() }
|
fun List<ApiBookmark>.toDomainEntitiesList(): List<Bookmark> = map { it.toDomainEntity() }
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.moire.ultrasonic.domain
|
||||||
|
|
||||||
|
import org.moire.ultrasonic.domain.MusicDirectory.Entry
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
data class Bookmark(
|
||||||
|
val position: Int = 0,
|
||||||
|
val username: String,
|
||||||
|
val comment: String,
|
||||||
|
val created: Date? = null,
|
||||||
|
val changed: Date? = null,
|
||||||
|
val entry: Entry
|
||||||
|
) : Serializable {
|
||||||
|
companion object {
|
||||||
|
private const val serialVersionUID = 8988990025189807803L
|
||||||
|
}
|
||||||
|
}
|
@ -22,8 +22,8 @@ class APIBookmarkConverterTest {
|
|||||||
|
|
||||||
with(domainEntity) {
|
with(domainEntity) {
|
||||||
position `should equal to` entity.position.toInt()
|
position `should equal to` entity.position.toInt()
|
||||||
username `should equal to` entity.username
|
username `should equal` entity.username
|
||||||
comment `should equal to` entity.comment
|
comment `should equal` entity.comment
|
||||||
created `should equal` entity.created?.time
|
created `should equal` entity.created?.time
|
||||||
changed `should equal` entity.changed?.time
|
changed `should equal` entity.changed?.time
|
||||||
entry `should equal` entity.entry.toDomainEntity()
|
entry `should equal` entity.entry.toDomainEntity()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user