草庐IT

Kotlin-script

全部标签

java - Kotlin:属性 setter 的文档

我正在编写一个Kotlin库。在其中一门课中,我有以下内容:classSessionWrapper{/***Thetimeinmillisecondsafterwhichthesessionwillexpire.*/varexpiryTime=DEFAULT_EXPIRY_TIMEget(){mainThreadCheck()returnfield}set(value){mainThreadCheck()field=valueupdateExpiry(value)然而,updateExpiry(long)的行为应该对SessionWrapper的客户端是透明的,如果他们修改expiry

java - Kotlin:属性 setter 的文档

我正在编写一个Kotlin库。在其中一门课中,我有以下内容:classSessionWrapper{/***Thetimeinmillisecondsafterwhichthesessionwillexpire.*/varexpiryTime=DEFAULT_EXPIRY_TIMEget(){mainThreadCheck()returnfield}set(value){mainThreadCheck()field=valueupdateExpiry(value)然而,updateExpiry(long)的行为应该对SessionWrapper的客户端是透明的,如果他们修改expiry

java - Kotlin Spring bean 验证可空性

在我用Kotlin构建的Spring应用程序中,我想在一个看起来像这样的数据类上使用bean验证。dataclassCustomerDto(@field:NotBlankvalfirstName:String,@field:NotBlankvallastName:String)在向客户端点发送firstName为空的帖子时,我想获得约束验证,但由于字段不允许空值,我没有获得验证,而是收到以下错误。"status":400,"error":"BadRequest","message":"JSONparseerror:Instantiationof[simpletype,classpkg.

java - Kotlin Spring bean 验证可空性

在我用Kotlin构建的Spring应用程序中,我想在一个看起来像这样的数据类上使用bean验证。dataclassCustomerDto(@field:NotBlankvalfirstName:String,@field:NotBlankvallastName:String)在向客户端点发送firstName为空的帖子时,我想获得约束验证,但由于字段不允许空值,我没有获得验证,而是收到以下错误。"status":400,"error":"BadRequest","message":"JSONparseerror:Instantiationof[simpletype,classpkg.

android - Dagger 单例 vs Kotlin 对象

要定义一个单例,我应该使用Kotlin对象声明还是创建一个普通的Kotlin类并使用dagger注入(inject)它?在我看来,第一种选择肯定更容易,但在这种情况下使用Dagger可能是有原因的,我不知道。选项1(注意object关键字):objectSomeUtil{//objectstate(properties)funsomeFunction(number:Long){//...}}选项2(注意class关键字):classSomeUtil{//objectstate(properties)funsomeFunction(number:Long){//...}}@Modulec

android - Dagger 单例 vs Kotlin 对象

要定义一个单例,我应该使用Kotlin对象声明还是创建一个普通的Kotlin类并使用dagger注入(inject)它?在我看来,第一种选择肯定更容易,但在这种情况下使用Dagger可能是有原因的,我不知道。选项1(注意object关键字):objectSomeUtil{//objectstate(properties)funsomeFunction(number:Long){//...}}选项2(注意class关键字):classSomeUtil{//objectstate(properties)funsomeFunction(number:Long){//...}}@Modulec

kotlin - 二次构造语法 kotlin

我有以下带有主构造函数的kotlin类,classPerson(first:String,last:String,age:Int){init{println("Initializing")}}我想添加一个辅助构造函数,它将全名解析为first和last名称并调用主构造函数。但是,我无法正确使用语法...classPerson(first:String,last:String,age:Int){//Secondaryconstructorconstructor(fullname:String,age:Int):this("first","last",age){println("Insec

kotlin - 二次构造语法 kotlin

我有以下带有主构造函数的kotlin类,classPerson(first:String,last:String,age:Int){init{println("Initializing")}}我想添加一个辅助构造函数,它将全名解析为first和last名称并调用主构造函数。但是,我无法正确使用语法...classPerson(first:String,last:String,age:Int){//Secondaryconstructorconstructor(fullname:String,age:Int):this("first","last",age){println("Insec

Android Studio 3 金丝雀 & Kotlin

有没有人收到“Kotlin未配置”的消息我确定我错过了一些东西,但在大多数情况下我下载了它,只是让它导入了我现有的2.x设置。我尝试从java类简单地复制/粘贴到新的Kotlin文件中,这就是我所在的位置。这是我当前的顶级build.gradlebuildscript{repositories{jcenter{url="http://jcenter.bintray.com/"}maven{url="https://maven.google.com"}mavenCentral()}dependencies{classpath'com.android.tools.build:gradle:

Android Studio 3 金丝雀 & Kotlin

有没有人收到“Kotlin未配置”的消息我确定我错过了一些东西,但在大多数情况下我下载了它,只是让它导入了我现有的2.x设置。我尝试从java类简单地复制/粘贴到新的Kotlin文件中,这就是我所在的位置。这是我当前的顶级build.gradlebuildscript{repositories{jcenter{url="http://jcenter.bintray.com/"}maven{url="https://maven.google.com"}mavenCentral()}dependencies{classpath'com.android.tools.build:gradle: