mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.3 KiB
Kotlin
32 lines
1.3 KiB
Kotlin
package org.tasks.makers
|
|
|
|
import com.natpryce.makeiteasy.Instantiator
|
|
import com.natpryce.makeiteasy.Property
|
|
import com.natpryce.makeiteasy.Property.newProperty
|
|
import com.natpryce.makeiteasy.PropertyValue
|
|
import org.tasks.data.CaldavTask
|
|
import org.tasks.makers.Maker.make
|
|
|
|
object CaldavTaskMaker {
|
|
val CALENDAR: Property<CaldavTask, String> = newProperty()
|
|
val TASK: Property<CaldavTask, Long> = newProperty()
|
|
val REMOTE_ID: Property<CaldavTask, String?> = newProperty()
|
|
val REMOTE_PARENT: Property<CaldavTask, String?> = newProperty()
|
|
val REMOTE_ORDER: Property<CaldavTask, Long?> = newProperty()
|
|
val ETAG: Property<CaldavTask, String?> = newProperty()
|
|
val OBJECT: Property<CaldavTask, String?> = newProperty()
|
|
|
|
private val instantiator = Instantiator<CaldavTask> {
|
|
val task = CaldavTask(it.valueOf(TASK, 1L), it.valueOf(CALENDAR, "calendar"))
|
|
task.remoteId = it.valueOf(REMOTE_ID, task.remoteId)
|
|
task.remoteParent = it.valueOf(REMOTE_PARENT, null as String?)
|
|
task.order = it.valueOf(REMOTE_ORDER, null as Long?)
|
|
task.etag = it.valueOf(ETAG, null as String?)
|
|
task.`object` = it.valueOf(OBJECT, task.remoteId?.let { id -> "$id.ics" })
|
|
task
|
|
}
|
|
|
|
fun newCaldavTask(vararg properties: PropertyValue<in CaldavTask?, *>): CaldavTask {
|
|
return make(instantiator, *properties)
|
|
}
|
|
} |