Lance Clark
12/02/2022, 2:46 PMHe
12/02/2022, 11:44 PMfun wait(){
val timeout= TimeHelper.getNow() + timeoutInterval // <- part of class constructor
if(processor.getLag() > 0){
val currentTIme = TimeHelper.getNow()
if(currentTime >= timeout){ System.exit(42) }
Thread.sleep(someTime)
}
}
Is there a way for me to use mockk to either that wait()
has executed for x amount of time with verify(exactly = x) { someProcessor.wait() }
, or Thread.sleep()
has been sleeping for x number of time?
I have something like this in my test class
every { processor.getLag() } returns 1
every { TimeHelper.getNow() } returns 100
So after some number of executions ever{ processor.getLag() } returns 0
to validate that it finishesMustafa Ozhan
12/03/2022, 4:41 PMfun exampleMethod() = "SomeString" // want to have warning/error
fun exampleMethod(): String = "SomeString" // this should pass
xun su
12/04/2022, 3:13 AMval return5 = {5}
I think it is equal to
fun return5(): Int {
// note return here
return 5
}
if so, please explain the code bellow:
fun test(fn: () -> Unit) {}
val foo =
fun(name: String): String {
return name
}
test { foo } // why no error ?
I mean ,test
accept a parameter , which is a function with the type ()->Unit
, but I think test { foo }
is equals to
test(
fun() {
return foo
})
Apparently it mismatch the type of parameter fn
of the function test
, the case above is () -> String -> String
, but why no error here ?
``` ```LIRAN Y
12/04/2022, 5:45 PMremovePrefix()
if i have this string
Expiration Date: "2023-01-03 16:06:52 +0000 UTC"
and i want to get "2023-01-03 16:06:52 +0000 UTC"
chiroptical
12/04/2022, 11:03 PMcorneil
12/05/2022, 6:45 PMzt
12/06/2022, 6:28 AMDiego DeSouza
12/07/2022, 4:15 PMmin(10, 2)
error: unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun <T : Comparable<TypeVariable(T)>> Array<out TypeVariable(T)>.min(): TypeVariable(T) defined in kotlin.collections
public fun Array<out Double>.min(): Double defined in kotlin.collections
public fun Array<out Float>.min(): Float defined in kotlin.collections
public fun ByteArray.min(): Byte defined in kotlin.collections
Ken
12/07/2022, 11:26 PMchiroptical
12/08/2022, 2:01 AMT?
. In Haskell, I use the maybe function pretty frequently. The type is like (default: U, f: (T) -> U, x: T?): U
Jakub Chrzanowski
12/09/2022, 9:32 AMsrcDirs
property provides Set<File!>
I further use with .map(File::toPath)
– I assume it’s rather necessary to .filterNotNull()
before, right?
2. As I have couple of chained operations – wouldn’t it be better to convert the initial set to sequence?Alan B
12/09/2022, 1:15 PMLuke Armitage
12/09/2022, 11:31 PMJoshua Hansen
12/10/2022, 5:07 AMelye
12/10/2022, 7:35 AMAdd a custom getter to make the val lazy really lazy. It should be initialized by invoking initializer() during the first access.
You can add any additional properties as you need.
Do not use delegated properties!
The answer code is
class LazyProperty(val initializer: () -> Int) {
var value: Int? = null
val lazy: Int
get() {
if (value == null) {
value = initializer()
}
return value!!
}
}
I tried the below and it also pass
class LazyProperty(val initializer: () -> Int) {
val lazy by lazy {
initializer()
}
}
I'm not sure the intent of this tutorial introducing lazy
, but not using by lazy
. Is it to show us the get()
instead?
Thanks 🙏Jakub Gwóźdź
12/10/2022, 8:01 AMfoo
and bar
.
in bar.Baz.kt
I have this:
package bar
fun baz(i: Int) = i + 1
and in foo.Foo.kt
this:
package foo
import bar.baz
fun xd(op: (Int) -> Int) {
println("calling $op with param 4 and getting ${op(4)}")
}
fun main() {
xd(::baz)
}
everything works great.
now I want to get rid of import bar.baz
. How do I do that? xd(::bar.baz)
does not compile. What’s the syntax here?PHondogo
12/10/2022, 7:58 PMGavin Ray
12/10/2022, 10:27 PMColton Idle
12/11/2022, 4:24 AMarray.forEachIndexed { indexOuter, outer ->
array.forEachIndexed { indexInnter, inner ->
//I want this inner forEachIndexed to start at indexOuter++
}
}
Colton Idle
12/11/2022, 5:04 AMElizeu Silva dos Santos
12/11/2022, 4:55 PMdata class A (
val id: String,
val b: B
)
enum class B{
AA, BB, CC
}
Trying to run the app I have the following error: Exception in thread "main" com.apurebase.kgraphql.schema.SchemaException: Cannot handle enum class class com.example.B as Object type
. Does someone know how to solve it?André Martins
12/12/2022, 10:56 AMcompiled code
on the method implementations, any ideias?Dickens A S
12/12/2022, 11:42 AMStylianos Gakis
12/12/2022, 2:02 PMStateFlow<Foo>
and had it behind a function stateFlow(): StateFlow<Foo>
but the implementation simply had the private declaration and the overridden function was simply doing return this.stateFlow
.
So I wonder, is it weird for the interface to simply expose val stateFlow: StateFlow<Foo>
instead? Are there any reasons why I would want to avoid that?Viktor Sirotin
12/12/2022, 2:09 PMAaron Barsky
12/12/2022, 4:57 PM/Users/abarsky/AndroidStudioProjects/KotlinMultiplatformSandbox/build/ios/Debug-iphonesimulator/iosApp.app
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@3d723a8 from other thread
at 0 shared 0x10375ea73 kfun:kotlin.Throwable#<init>(kotlin.String?){} + 95
at 1 shared 0x103757f93 kfun:kotlin.Exception#<init>(kotlin.String?){} + 91
at 2 shared 0x1037581c7 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 91
at 3 shared 0x10376a393 kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} + 91
at 4 shared 0x10376ce9b ThrowIllegalObjectSharingException + 415
at 5 shared 0x103b0a02f _ZN12_GLOBAL__N_128throwIllegalSharingExceptionEP9ObjHeader + 27
at 6 shared 0x103b0b5f7 _ZN12_GLOBAL__N_136terminateWithIllegalSharingExceptionEP9ObjHeader + 11
at 7 shared 0x103b0b7a7 _ZNK27BackRefFromAssociatedObject3refIL11ErrorPolicy3EEEP9ObjHeaderv + 231
at 8 shared 0x103b0a837 _ZN12_GLOBAL__N_111toKotlinImpEP11objc_objectP13objc_selectorPP9ObjHeader + 51
at 9 shared 0x103b011ab Kotlin_Interop_refFromObjC + 111
at 10 shared 0x1039e2cbb _696f2e6b746f723a6b746f722d636c69656e742d64617277696e_knbridge101 + 207
at 11 shared 0x103acb7cb _696f2e6b746f723a6b746f722d636c69656e742d64617277696e_kncfun103 + 79
at 12 CFNetwork 0x1049e37cf /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CFNetwork.framework/CFNetwork + 47055
at 13 Foundation 0x105e4f8d7 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 15
at 14 Foundation 0x105e4f7cb -[NSBlockOperation main] + 99
at 15 Foundation 0x105e524f3 __NSOPERATION_IS_INVOKING_MAIN__ + 11
as the httpClient line is executed
@Throws(Exception::class)
suspend fun greeting(): String {
val rockets: List<RocketLaunch> =
httpClient.get("<https://api.spacexdata.com/v4/launches>").body()
Here are my plugin versions
plugins {
//trick: for the same plugin versions in all sub-modules
id("com.android.application").version("7.3.1").apply(false)
id("com.android.library").version("7.3.1").apply(false)
kotlin("android").version("1.7.10").apply(false)
kotlin("multiplatform").version("1.7.10").apply(false)
}
which were setup automatically for me when I made a new Kotlin Multiplatform App from within Android studio. https://kotlinlang.org/docs/multiplatform-mobile-create-first-app.html
Running XCode 14.. Is there a complete project I can download to make sure it's not a mistake typing in the tutorial code?He
12/13/2022, 2:12 AMclass someClass(){
lateinit var one: String,
lateinit var two: String,
lateinit var three: customObject
}
So what I'm doing is throughout my code I'm updating these variables based on some conditions/criteria and I have another class that calls someClass
and I will use getters to retrieve the lateinit var
. Instead of these singleton variables, what should I be using? Should I be using a custom data class
to store the state of the variables?
The logic I have for these variables:
one - Does the data already exist? yes -> one = existingData.one no -> one = generate some value and set
two - Does the data already exist? yes -> two = existingData.two no -> two = generate some value and set && Are we done? yes -> no nothing. no -> generate some value and set
three - Just update consistently to get the most recent Object to be passed into different classsarvagya agarwal
12/13/2022, 5:14 AMjava.lang.RuntimeException: java.rmi.RemoteException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException:Cannot construct instance of `com.arcesium.recon.workflow.domain.BreakAnalysis` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (String)"{
"@UUID" : "46435929-0621-40b9-b623-871dda721fdf",
"breakAnalysisList" : [ {
"@UUID" : "d339332a-babf-49b6-a17e-05584595810b",
"id" : -1,
"key" : {
"@UUID" : "a96c68bb-4f80-49aa-b346-67a34b564123",
"recUnitKey" : "1e364133-a8c1-590f-b13c-41e2f4e661bd",
"componentId" : 67,
"breakAnalysisId" : -1
},
"recGrainId" : 136,
"openDate" : "2022-03-28",
"closeDate" : "2022-04-08",
"amount" : -0.58,
"isChild" : false,
"ttBegin" : "2022-12"[truncated 1484 chars]; line: 4, column: 5] (through reference chain: com.arcesium.recon.workflow.domain.BreakAnalysisRequest["breakAnalysisList"]->java.util.ArrayList[0]). For further assistance, please contact - <mailto:help@arcesium.com|help@arcesium.com> with tracking request id : 3e3453cc-0549-4117-81a7-c34530095500
at com.arcesium.frames.client.RESTfulClient.handleThrowable(RESTfulClient.java:599)
at com.arcesium.frames.client.RESTfulClient.executePost(RESTfulClient.java:479)
at com.arcesium.frames.client.RESTfulClient.executePost(RESTfulClient.java:637)
at com.arcesium.frames.service.util.JavaLightHelper.callRestMethod(JavaLightHelper.java:336)
at com.arcesium.frames.client.api.proxy.ClientProxyUtils.executeApi(ClientProxyUtils.java:298)
at com.arcesium.frames.client.api.proxy.RemoteProxy.invoke(RemoteProxy.java:304)
at com.sun.proxy.$Proxy266.createBreakAnalysis(Unknown Source)
at deshaw.munshi.reconcilers.service.util.BreakSyncUtil.createBreakSync(BreakSyncUtil.kt:181)
at deshaw.munshi.reconcilers.service.util.BreakSyncUtil$$FastClassBySpringCGLIB$$b6334f06.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.rmi.RemoteException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException:Cannot construct instance of `com.arcesium.recon.workflow.domain.BreakAnalysis` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (String)"{
"@UUID" : "46435929-0621-40b9-b623-871dda721fdf",
"breakAnalysisList" : [ {
"@UUID" : "d339332a-babf-49b6-a17e-05584595810b",
"id" : -1,
"key" : {
"@UUID" : "a96c68bb-4f80-49aa-b346-67a34b564123",
"recUnitKey" : "1e364133-a8c1-590f-b13c-41e2f4e661bd",
"componentId" : 67,
"breakAnalysisId" : -1
},
"recGrainId" : 136,
"openDate" : "2022-03-28",
"closeDate" : "2022-04-08",
"amount" : -0.58,
"isChild" : false,
"ttBegin" : "2022-12"[truncated 1484 chars]; line: 4, column: 5] (through reference chain: com.arcesium.recon.workflow.domain.BreakAnalysisRequest["breakAnalysisList"]->java.util.ArrayList[0]).
Adding a default constructor doesn't help , does anyone have any idea how to resolve this ?
This is how my class looks like
data class BreakAnalysis(
var id: Long,
val key: BreakAnalysisKey,
val recGrainId: Int,
val openDate: LocalDate,
val closeDate: LocalDate,
val amount: BigDecimal,
val isChild: Boolean?,
var associatedBreakIds: List<Long>?,
val ttBegin: LocalDateTime,
val ttEnd: LocalDateTime,
val systemInsertionRuleId: Int?,
val groupId: Long,
val partitionDate: LocalDate,
val associatedBreakMetaData: Map<String, Any>?,
val breakMetadata: Map<String, Any>?,
val recTypeFamilyId: Int,
val reasonId: Int,
val ageStartDate: LocalDate,
val cpidDetails: Map<String, Any?>?,
val expressionEvaluationDetails: Map<String, Any?>?,
val grainMap: Map<String, Any?>?,
val clientUserName: String?,
val createdBy: String?,
val updatedBy: String?,
val previousModificationBy: String?,
val isWriteOff: Boolean?,
val comments: String?,
val clientComments: String?,
val wireId: Int?,
val userTranId: String?,
val settlementPrice: BigDecimal?,
val side1Quantity: BigDecimal?,
val side2Quantity: BigDecimal?,
val side1Amount: BigDecimal?,
val side2Amount: BigDecimal?,
val tick: BigDecimal?,
val side1TradePrice: BigDecimal?,
val side2TradePrice: BigDecimal?,
val adminInvestmentCode: String?,
val investmentDescription: String?,
val recStatusId: Int,
val breakAnalysisWorkflow: BreakAnalysisWorkflow?,
val attachments: List<Attachment>,
val workUnitId: Int,
val workUnitTypeId: Int,
val contributedToComponentIds: Set<Int>?,
val reconManifestationId: Long?,
val uiWorkUnitId: Int?
) {
constructor(): this(-1, BreakAnalysisKey(),-1,LocalDate.now(),LocalDate.now(),
BigDecimal.valueOf(0),null,null,LocalDateTime.now(),
LocalDateTime.now(),null,-1,LocalDate.now(),null,
null,1,-1,LocalDate.now(),null,null,
null,null,null,null,null,null,
null,null,null,null,null,null,
null,null,null,null,null,null,
null,null,-1, null, emptyList(),
-1,-1,null,null,null
)
}
Zea
12/13/2022, 7:20 AMZea
12/13/2022, 7:20 AMAndreyVanDenHaag
12/13/2022, 7:27 AMZea
12/13/2022, 7:29 AMVampire
12/13/2022, 7:55 AM