Skip to content
Snippets Groups Projects
Commit 036618dc authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Fixed return route values, improved settings code

parent 80276e2e
No related branches found
No related tags found
No related merge requests found
......@@ -21,4 +21,19 @@ import com.j256.ormlite.table.DatabaseTable
}
def getId: Int = id
def canEqual(other: Any): Boolean = other.isInstanceOf[Account]
override def equals(other: Any): Boolean = other match {
case that: Account =>
(that canEqual this) &&
id == that.id
case _ => false
}
override def hashCode(): Int = {
val state = Seq(id)
state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
}
}
......@@ -25,6 +25,7 @@ import scala.util.Random
}
def getId: Int = id
def getAccount: Account = account
}
object Session {
......
......@@ -5,12 +5,12 @@ package de.tobias.playpad.server.server
*/
class Result {
var status: Status.Value = _
var status: String = _
var message: String = _
def this(status: Status.Value, message: String = "") {
this()
this.status = status
this.status = status.toString
this.message = message
}
}
......@@ -33,13 +33,13 @@ class SessionPost(accountDao: Dao[Account, Int]) extends Route {
}
private class SessionPostResult {
var status: Status.Value = _
var status: String = _
var message: String = _
var key: String = _
def this(status: Status.Value, key: String, message: String = "") {
this()
this.status = status
this.status = status.toString
this.message = message
this.key = key
}
......
......@@ -16,7 +16,8 @@ class PropertiesSettingsHandler extends SettingsLoader with SettingsSaver {
properties.load(Files.newBufferedReader(path))
val settings = new Settings()
classOf[Settings].getDeclaredFields.filter(f => !Modifier.isTransient(f.getModifiers))
classOf[Settings].getDeclaredFields
.filter(f => !Modifier.isTransient(f.getModifiers))
.filter(f => properties.containsKey(f.getName))
.foreach(f => {
f.setAccessible(true)
......@@ -33,9 +34,8 @@ class PropertiesSettingsHandler extends SettingsLoader with SettingsSaver {
override def save(settings: Settings, path: Path): Unit = {
val properties = new Properties()
println("Save")
classOf[Settings].getDeclaredFields.filter(f => !Modifier.isTransient(f.getModifiers))
classOf[Settings].getDeclaredFields
.filter(f => !Modifier.isTransient(f.getModifiers))
.foreach(f => {
f.setAccessible(true)
properties.setProperty(f.getName, f.get(settings).toString)
......
......@@ -11,5 +11,5 @@ trait SettingsSaver {
@throws[IOException]
def save(settings: Settings, path: Path)
def default(path: Path) = save(new Settings(), path)
def default(path: Path): Unit = save(new Settings(), path)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment