mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-06-06 18:43:05 +03:00
Convert Indexes domain entity to kotlin.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
21b3fcc77c
commit
9ddd68f941
@ -1,66 +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;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Sindre Mehus
|
|
||||||
*/
|
|
||||||
public class Indexes implements Serializable
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 8156117238598414701L;
|
|
||||||
private final long lastModified;
|
|
||||||
private final String ignoredArticles;
|
|
||||||
private final List<org.moire.ultrasonic.domain.Artist> shortcuts;
|
|
||||||
private final List<org.moire.ultrasonic.domain.Artist> artists;
|
|
||||||
|
|
||||||
public Indexes(long lastModified, String ignoredArticles, List<Artist> shortcuts, List<Artist> artists)
|
|
||||||
{
|
|
||||||
this.lastModified = lastModified;
|
|
||||||
this.ignoredArticles = ignoredArticles;
|
|
||||||
this.shortcuts = shortcuts;
|
|
||||||
this.artists = artists;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLastModified()
|
|
||||||
{
|
|
||||||
return lastModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<org.moire.ultrasonic.domain.Artist> getShortcuts()
|
|
||||||
{
|
|
||||||
return shortcuts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<org.moire.ultrasonic.domain.Artist> getArtists()
|
|
||||||
{
|
|
||||||
return artists;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIgnoredArticles()
|
|
||||||
{
|
|
||||||
return ignoredArticles;
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,9 @@ import org.moire.ultrasonic.api.subsonic.models.Index
|
|||||||
import org.moire.ultrasonic.api.subsonic.models.Indexes as APIIndexes
|
import org.moire.ultrasonic.api.subsonic.models.Indexes as APIIndexes
|
||||||
|
|
||||||
fun APIIndexes.toDomainEntity(): Indexes = Indexes(this.lastModified, this.ignoredArticles,
|
fun APIIndexes.toDomainEntity(): Indexes = Indexes(this.lastModified, this.ignoredArticles,
|
||||||
this.shortcutList.map { it.toDomainEntity() }, this.indexList.foldIndexToArtistList())
|
this.shortcutList.map { it.toDomainEntity() }.toMutableList(),
|
||||||
|
this.indexList.foldIndexToArtistList().toMutableList()
|
||||||
|
)
|
||||||
|
|
||||||
private fun List<Index>.foldIndexToArtistList(): List<Artist> = this.fold(listOf(), {
|
private fun List<Index>.foldIndexToArtistList(): List<Artist> = this.fold(listOf(), {
|
||||||
acc, index -> acc + index.artists.map { it.toDomainEntity() }
|
acc, index -> acc + index.artists.map { it.toDomainEntity() }
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.moire.ultrasonic.domain
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
data class Indexes(
|
||||||
|
val lastModified: Long,
|
||||||
|
val ignoredArticles: String,
|
||||||
|
val shortcuts: MutableList<Artist> = mutableListOf(),
|
||||||
|
val artists: MutableList<Artist> = mutableListOf()
|
||||||
|
) : Serializable {
|
||||||
|
companion object {
|
||||||
|
private const val serialVersionUID = 8156117238598414701L
|
||||||
|
}
|
||||||
|
}
|
@ -44,7 +44,7 @@ class APIPlaylistConverterTest {
|
|||||||
name `should equal to` entity.name
|
name `should equal to` entity.name
|
||||||
comment `should equal to` entity.comment
|
comment `should equal to` entity.comment
|
||||||
owner `should equal to` entity.owner
|
owner `should equal to` entity.owner
|
||||||
public `should equal to` entity.public
|
public `should equal` entity.public
|
||||||
songCount `should equal to` entity.songCount.toString()
|
songCount `should equal to` entity.songCount.toString()
|
||||||
created `should equal to` playlistDateFormat.format(entity.created?.time)
|
created `should equal to` playlistDateFormat.format(entity.created?.time)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user