kotlin

How to implement @RequestPart in a reactive, functional (not annotated) webflux service?

别说谁变了你拦得住时间么 提交于 2020-08-09 08:15:17
问题 I have a Spring Boot 2, reactive webflux web service, which persists uploaded, multipart fileparts to MongoDB's GridFS. This is working properly. Today, a request was made to include metadata for the files being added to GridFS. Unfortunately, I have not been able to get it to work with my functional/non-annotated web service. I would appreciate any suggestions or nudges in the correct direction. Here are the details: An example of the request being sent to my endpoint: curl -X "POST" "http:/

How to include Kotlin PSI classes (e.g. KtClass) in Intellij IDEA Gradle plugin project written in Kotlin?

杀马特。学长 韩版系。学妹 提交于 2020-08-09 04:43:56
问题 I am trying to write a plugin to add mock data to a Kotlin project. The first part involves finding all the Kotlin classes in the current project that inherits from a specific base class. I want to be able to parse these classes to read the value of an annotation and to get the structure of the constructor. This information will then be used to add code to the project adding instances of selected classes to a mock database instance. I have been using the PsiViewer plugin to inspect the PSI

【21】kotlin 扩展成员 扩展方法

流过昼夜 提交于 2020-08-09 03:00:48
java中我们常常需要定义很多工具类 package com.yzdzy.kotlin.chapter4.extend; public class Utils { public static boolean isEmpty(String[] args) { return args == null || args.length == 0; } public static boolean isNotEmpty(String[] args) { return args != null && args.length >= 0; } } package com.yzdzy.kotlin.chapter4.extend; public class ExtemdsJava { public static void main(String[] args) { if(args.length==0){ } if(args.length!= 0) { } Utils.isEmpty(args); Utils.isNotEmpty(args); } } 而kt 提供了扩展方法 当然我饿米也可以自己定义扩展方法 下面案例打印16次adc package com.yzdzy.kotlin.chapter4.extend import java.lang.StringBuilder fun main(args:

How to emit Flow value from different function? Kotlin Coroutines

牧云@^-^@ 提交于 2020-08-09 02:42:37
问题 I have a flow : val myflow = kotlinx.coroutines.flow.flow<Message>{} and want to emit values with function: override suspend fun sendMessage(chat: Chat, message: Message) { myflow.emit(message) } But compiler does not allow me to do this, is there any workarounds to solve this problem? 回答1: The answer of Animesh Sahu is pretty much correct. You can also return a Channel as a flow (see consumeAsFlow or asFlow on a BroadcastChannel). But there is also a thing called StateFlow currently in

How to emit Flow value from different function? Kotlin Coroutines

拥有回忆 提交于 2020-08-09 02:41:56
问题 I have a flow : val myflow = kotlinx.coroutines.flow.flow<Message>{} and want to emit values with function: override suspend fun sendMessage(chat: Chat, message: Message) { myflow.emit(message) } But compiler does not allow me to do this, is there any workarounds to solve this problem? 回答1: The answer of Animesh Sahu is pretty much correct. You can also return a Channel as a flow (see consumeAsFlow or asFlow on a BroadcastChannel). But there is also a thing called StateFlow currently in

编程语言最新排名:Java最受欢迎、JS用户最多

梦想与她 提交于 2020-08-08 10:13:55
IDE工具开发商JetBrains基于2万名开发者,对编程语言的最新情况进行了统计描摹。就受欢迎程度而言,Java高居第一位,但在使用人数上,JavaScript则名列榜首。 欢迎程度的统计方法是,让参与的开发者选出三种立即觉得必要的语音,最后算结果。 被访问时,JetBrains负责人指出,Java最后欢迎是因为很多项目都用JavaScript,但在后者身上并不花费很多时间。 另外就使用情况而言,Python超越了Java,这可能与机器学习浪潮大热有关。 最后是对于新语言的兴趣,Go、Kotlin、Rust、TypeScript、Swift、Dart等在列。 如果有收获?希望老铁们来个三连,点赞、收藏、转发 创作不易,别忘点个赞,可以让更多的人看到这篇文章,顺便鼓励我写出更好的博客 大家有什么要说的,欢迎在评论区留言 对了,小编还为大家准备了一套2020最新的Java资料,需要的自取 1、点赞+评论(勾选“同时转发”) 2、关注小编。并私信回复关键字【学习】(一定要私信哦~手机点击我的头像就能看到私信按钮了),部分资料如下 来源: oschina 链接: https://my.oschina.net/u/4347381/blog/4390132

Android UI tests with Espresso + MockK crash with SIGSEGV on emulators, fine on physical devices

…衆ロ難τιáo~ 提交于 2020-08-08 05:14:10
问题 I have just started using MockK to mock all the Repositories / Services logic in an MVP-based app for UI tests. I have some UI tests running a login activity where the Espresso inputs logins and passwords and using MockK I can fake various situation where the login fails or not. All services & repositories are standard Kotlin object, so I am using mockkobject and every/coEvery to override and handle login requests & tasks. On my physical devices, there are no issues with the tests at all, but

Implement Java method that returns Collection in Kotlin

余生颓废 提交于 2020-08-08 05:13:35
问题 I'm using Kotlin with Spring Security. When implementing this method: public interface UserDetails extends Serializable { Collection<? extends GrantedAuthority> getAuthorities(); ... } I noticed Intellij generates this Kotlin code: override fun getAuthorities(): MutableCollection<out GrantedAuthority> { ... } ... which makes sense since java.util.Collection is mutable. However, if I replaced the MutableCollection with Collection (which should be kotlin.collections.Collection IIRC), the code

2020 年 HackerEarth 调查:Go 语言成为最受欢迎的语言(内含 Go 语言图谱下载)

最后都变了- 提交于 2020-08-08 03:58:44
<关注阿里巴巴云原生公众号,回复 Go 即可下载清晰知识图谱> 对 Go 语言感兴趣但又不知从何学起的同学,可以参考一下 Go 语言系列文章: 为什么你要选择 Go? Go 面向失败编程 带着服务器编程金刚经走进 2020 年 敢问路在何方? 近日 HackerEarth 发布了 2020 年开发者调查报告,有来自 76 个国家和地区的 16,000 多位开发者参与其中。 HackerEarth 联合创始人兼首席执行官 Sachin Gupta 在报告中提到:「今天技术开发者人才的短缺达到了自 2008 年以来的最高值,招聘者想要得到开发者们的青睐变得难上加难。」 这个观点似乎和我们的普遍想法不同,在中国的互联网上总是有「开发岗位」已经饱和的声音,或经常听到某公司的一个开发岗位有几十人争夺的新闻,那么 Sachin Gupta 究竟为什么会得到这样的观点呢?让我们一起来看下这份报告。 以下是报告的详细解读: 报告调查重点: Go 是今年最受欢迎的编程语言。无论是学生(29%)还是专业人士(32%),都将 Go 语言列在**「最想学习的语言」**第一位。受访的学生最想学习的语言还有 JavaScript 和 Kotlin,而专业人士将 Python 和 Kotlin 作为接下来的选择。 开发者技能篇 1. 到了 2020 年,数据科学仍占统治地位 数据科学无止境!从学生开发人员(63

Kotlin+Vue+Spring Data JPA+MySQL 增查改删

半腔热情 提交于 2020-08-08 00:52:49
概述: Kotlin为后端开发语言,持久层是Spring Data JPA 前后端分离,进行简单增查改删(CRUD) 前端使用VUE 数据库使用MySQL 往期内容 # 内容 01 React+Spring Boot JPA+MySQL 增查改删 02 Vue+Spring Boot JPA+MySQL 增查改删 增查改删 03 Vue+Spring Boot 文件操作,上传、预览和删除 04 Thymeleaf+Spring Boot 文件操作,上传、预览和删除 Vue前端代码,不再重复。以下是Kotlin后台代码 #EmployeeController.kt package com.example.kotlinjpacrud.controller import com.example.kotlinjpacrud.entity.Employee import com.example.kotlinjpacrud.repositories.EmployeeRepository import org.springframework. data .domain.Page import org.springframework. data .domain.Pageable import org.springframework. data .domain.Sort import org