Skip to content

Instantly share code, notes, and snippets.

View agustarc's full-sized avatar
🎯
Focusing

Leopold agustarc

🎯
Focusing
View GitHub Profile
implementation 'com.github.AgustaRC.koap:koap:1.0.1'
repositories {
maven { url 'https://jitpack.io' }
}
object AccountPreference : PreferenceHolder(name = "account", cacheStrategy = CacheStrategy.LAZY) {
var name: String by ReadWriteString(predicate = { it.length > 2 })
var age: Int by ReadWriteInt(default = 1, caching = false)
var hireable: Boolean by ReadWriteBoolean()
var score: Float by ReadWriteFloat(default = 0.1f)
var repos: Long by ReadWriteLong()
var followers: ArrayList<User>? by ReadWriteSerializable(type = inferType<ArrayList<User>>())
var friend: User? by ReadWriteSerializable(type = inferType<User>())
}
public interface Account {
@NotNull
String getName();
void setName(@NotNull String var1);
int getAge();
void setAge(int var1);
object AccountPreference : PreferenceHolder() {
var name: String by ReadWriteString(key = "pref_name", default = "leopold", predicate = { it.length > 2 })
var age: Int by ReadWriteInt()
var hireable: Boolean by ReadWriteBoolean()
}
@Preference
interface Account {
@PreferenceField(key = "pref_name", default = "leopold", predicate = { it.length > 2 })
var name: String
var age: Int
var hireable: Boolean
}
class Point(val x: Double, val y: Double) {
companion object {
fun fromPolar(angle: Double, radius: Double) = Point(...)
}
}
when (x) {
null -> ...
else -> ...
}
if (x)
return foo()
else
return bar()
when(x) {
0 -> return "zero"
else -> return "nonzero"
}
return if (x) foo() else bar()
return when(x) {
0 -> "zero"
else -> "nonzero"
}