Migrate UserInfo to Kotlin.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-02-20 22:08:34 +01:00
parent 4218698a16
commit cb02582740
4 changed files with 39 additions and 199 deletions

View File

@ -1,182 +0,0 @@
/*
This file is part of UltraSonic.
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 2013 (C) Joshua Bahnsen
*/
package org.moire.ultrasonic.domain;
/**
* Information about the Subsonic server.
*
* @author Joshua Bahnsen
*/
public class UserInfo
{
private String userName;
private String email;
private boolean scrobblingEnabled;
private boolean adminRole;
private boolean settingsRole;
private boolean downloadRole;
private boolean uploadRole;
private boolean playlistRole;
private boolean coverArtRole;
private boolean commentRole;
private boolean podcastRole;
private boolean streamRole;
private boolean jukeboxRole;
private boolean shareRole;
public String getUserName()
{
return this.userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getEmail()
{
return this.email;
}
public void setEmail(String email)
{
this.email = email;
}
public boolean getScrobblingEnabled()
{
return this.scrobblingEnabled;
}
public void setScrobblingEnabled(boolean scrobblingEnabled)
{
this.scrobblingEnabled = scrobblingEnabled;
}
public boolean getAdminRole()
{
return this.adminRole;
}
public void setAdminRole(boolean adminRole)
{
this.adminRole = adminRole;
}
public boolean getSettingsRole()
{
return this.settingsRole;
}
public void setSettingsRole(boolean settingsRole)
{
this.settingsRole = settingsRole;
}
public boolean getDownloadRole()
{
return this.downloadRole;
}
public void setDownloadRole(boolean downloadRole)
{
this.downloadRole = downloadRole;
}
public boolean getUploadRole()
{
return this.uploadRole;
}
public void setUploadRole(boolean uploadRole)
{
this.uploadRole = uploadRole;
}
public boolean getPlaylistRole()
{
return this.playlistRole;
}
public void setPlaylistRole(boolean playlistRole)
{
this.playlistRole = playlistRole;
}
public boolean getCoverArtRole()
{
return this.coverArtRole;
}
public void setCoverArtRole(boolean coverArtRole)
{
this.coverArtRole = coverArtRole;
}
public boolean getCommentRole()
{
return this.commentRole;
}
public void setCommentRole(boolean commentRole)
{
this.commentRole = commentRole;
}
public boolean getPodcastRole()
{
return this.podcastRole;
}
public void setPodcastRole(boolean podcastRole)
{
this.podcastRole = podcastRole;
}
public boolean getStreamRole()
{
return this.streamRole;
}
public void setStreamRole(boolean streamRole)
{
this.streamRole = streamRole;
}
public boolean getJukeboxRole()
{
return this.jukeboxRole;
}
public void setJukeboxRole(boolean jukeboxRole)
{
this.jukeboxRole = jukeboxRole;
}
public boolean getShareRole()
{
return this.shareRole;
}
public void setShareRole(boolean shareRole)
{
this.shareRole = shareRole;
}
}

View File

@ -4,19 +4,19 @@ package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.User
fun User.toDomainEntity(): UserInfo = UserInfo().apply {
adminRole = this@toDomainEntity.adminRole
commentRole = this@toDomainEntity.commentRole
coverArtRole = this@toDomainEntity.coverArtRole
downloadRole = this@toDomainEntity.downloadRole
email = this@toDomainEntity.email
jukeboxRole = this@toDomainEntity.jukeboxRole
playlistRole = this@toDomainEntity.playlistRole
podcastRole = this@toDomainEntity.podcastRole
scrobblingEnabled = this@toDomainEntity.scrobblingEnabled
settingsRole = this@toDomainEntity.settingsRole
shareRole = this@toDomainEntity.shareRole
streamRole = this@toDomainEntity.streamRole
uploadRole = this@toDomainEntity.uploadRole
fun User.toDomainEntity(): UserInfo = UserInfo(
adminRole = this@toDomainEntity.adminRole,
commentRole = this@toDomainEntity.commentRole,
coverArtRole = this@toDomainEntity.coverArtRole,
downloadRole = this@toDomainEntity.downloadRole,
email = this@toDomainEntity.email,
jukeboxRole = this@toDomainEntity.jukeboxRole,
playlistRole = this@toDomainEntity.playlistRole,
podcastRole = this@toDomainEntity.podcastRole,
scrobblingEnabled = this@toDomainEntity.scrobblingEnabled,
settingsRole = this@toDomainEntity.settingsRole,
shareRole = this@toDomainEntity.shareRole,
streamRole = this@toDomainEntity.streamRole,
uploadRole = this@toDomainEntity.uploadRole,
userName = this@toDomainEntity.username
}
)

View File

@ -0,0 +1,21 @@
package org.moire.ultrasonic.domain
/**
* Information about user
*/
data class UserInfo(
val userName: String? = null,
val email: String? = null,
val scrobblingEnabled: Boolean = false,
val adminRole: Boolean = false,
val settingsRole: Boolean = false,
val downloadRole: Boolean = false,
val uploadRole: Boolean = false,
val playlistRole: Boolean = false,
val coverArtRole: Boolean = false,
val commentRole: Boolean = false,
val podcastRole: Boolean = false,
val streamRole: Boolean = false,
val jukeboxRole: Boolean = false,
val shareRole: Boolean = false
)

View File

@ -3,6 +3,7 @@
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.User
@ -22,7 +23,7 @@ class APIUserConverterTest {
commentRole `should equal to` entity.commentRole
coverArtRole `should equal to` entity.coverArtRole
downloadRole `should equal to` entity.downloadRole
email `should equal to` entity.email
email `should equal` entity.email
jukeboxRole `should equal to` entity.jukeboxRole
playlistRole `should equal to` entity.playlistRole
podcastRole `should equal to` entity.podcastRole
@ -31,7 +32,7 @@ class APIUserConverterTest {
shareRole `should equal to` entity.shareRole
streamRole `should equal to` entity.streamRole
uploadRole `should equal to` entity.uploadRole
userName `should equal to` entity.username
userName `should equal` entity.username
}
}
}