Convert Indexes domain entity to kotlin.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-02-22 21:46:53 +01:00
parent 21b3fcc77c
commit 9ddd68f941
4 changed files with 18 additions and 68 deletions

View File

@ -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;
}
}

View File

@ -7,7 +7,9 @@ import org.moire.ultrasonic.api.subsonic.models.Index
import org.moire.ultrasonic.api.subsonic.models.Indexes as APIIndexes
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(), {
acc, index -> acc + index.artists.map { it.toDomainEntity() }

View File

@ -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
}
}

View File

@ -44,7 +44,7 @@ class APIPlaylistConverterTest {
name `should equal to` entity.name
comment `should equal to` entity.comment
owner `should equal to` entity.owner
public `should equal to` entity.public
public `should equal` entity.public
songCount `should equal to` entity.songCount.toString()
created `should equal to` playlistDateFormat.format(entity.created?.time)
}