added visitor to TimerInfo
This commit is contained in:
parent
964cd8a6ae
commit
3c73c5a853
5 changed files with 27 additions and 7 deletions
|
@ -10,7 +10,6 @@ class CustomTimerInfo(
|
||||||
id: String = ""
|
id: String = ""
|
||||||
): TimerInfo(id, name, description) {
|
): TimerInfo(id, name, description) {
|
||||||
|
|
||||||
|
|
||||||
override fun getFunctionalTimer(): FunctionalTimer {
|
override fun getFunctionalTimer(): FunctionalTimer {
|
||||||
return FunctionalCustomTimer(studyTime)
|
return FunctionalCustomTimer(studyTime)
|
||||||
}
|
}
|
||||||
|
@ -24,4 +23,8 @@ class CustomTimerInfo(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <T> accept(visitor: TimerInfoVisitor<T>): T {
|
||||||
|
return visitor.visitCustomTimerInfo(this)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -22,4 +22,8 @@ class EndlessTimerInfo(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <T> accept(visitor: TimerInfoVisitor<T>): T {
|
||||||
|
return visitor.visitEndlessTimerInfo(this)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,13 +2,14 @@ package be.ugent.sel.studeez.data.local.models.timer_info
|
||||||
|
|
||||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
|
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
|
||||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||||
|
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimerVisitor
|
||||||
|
|
||||||
class PomodoroTimerInfo(
|
class PomodoroTimerInfo(
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
private val studyTime: Int,
|
val studyTime: Int,
|
||||||
private val breakTime: Int,
|
val breakTime: Int,
|
||||||
private val repeats: Int,
|
val repeats: Int,
|
||||||
id: String = ""
|
id: String = ""
|
||||||
): TimerInfo(id, name, description) {
|
): TimerInfo(id, name, description) {
|
||||||
|
|
||||||
|
@ -28,4 +29,8 @@ class PomodoroTimerInfo(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <T> accept(visitor: TimerInfoVisitor<T>): T {
|
||||||
|
return visitor.visitBreakTimerInfo(this)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,8 +7,8 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||||
*/
|
*/
|
||||||
abstract class TimerInfo(
|
abstract class TimerInfo(
|
||||||
val id: String,
|
val id: String,
|
||||||
val name: String,
|
var name: String,
|
||||||
val description: String
|
var description: String
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ abstract class TimerInfo(
|
||||||
* TODO implementaties hebben nog hardgecodeerde strings.
|
* TODO implementaties hebben nog hardgecodeerde strings.
|
||||||
*/
|
*/
|
||||||
abstract fun asJson(): Map<String, Any>
|
abstract fun asJson(): Map<String, Any>
|
||||||
|
abstract fun <T> accept(visitor: TimerInfoVisitor<T>): T
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
package be.ugent.sel.studeez.data.local.models.timer_info
|
package be.ugent.sel.studeez.data.local.models.timer_info
|
||||||
|
|
||||||
interface TimerInfoVisitor {
|
interface TimerInfoVisitor<T> {
|
||||||
|
|
||||||
|
fun visitCustomTimerInfo(customTimerInfo: CustomTimerInfo): T
|
||||||
|
|
||||||
|
fun visitEndlessTimerInfo(endlessTimerInfo: EndlessTimerInfo): T
|
||||||
|
|
||||||
|
fun visitBreakTimerInfo(pomodoroTimerInfo: PomodoroTimerInfo): T
|
||||||
|
|
||||||
}
|
}
|
Reference in a new issue