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.
34 lines
1.3 KiB
Kotlin
34 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 com.todoroo.astrid.helper.UUIDHelper
|
|
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 ETAG: Property<CaldavTask, String?> = newProperty()
|
|
val OBJECT: Property<CaldavTask, String?> = newProperty()
|
|
|
|
private val instantiator = Instantiator {
|
|
val remoteId = it.valueOf(REMOTE_ID, UUIDHelper.newUUID())
|
|
CaldavTask(
|
|
task = it.valueOf(TASK, 1L),
|
|
calendar = it.valueOf(CALENDAR, "calendar"),
|
|
remoteId = remoteId,
|
|
remoteParent = it.valueOf(REMOTE_PARENT, null as String?),
|
|
etag = it.valueOf(ETAG, null as String?),
|
|
`object` = it.valueOf(OBJECT, remoteId?.let { id -> "$id.ics" }),
|
|
)
|
|
}
|
|
|
|
fun newCaldavTask(vararg properties: PropertyValue<in CaldavTask?, *>): CaldavTask {
|
|
return make(instantiator, *properties)
|
|
}
|
|
} |