Hullaballoonatic
11/10/2019, 6:33 PMjojo.lichtenberger
11/11/2019, 9:09 AMSlackbot
11/11/2019, 10:08 AMBurkhard
11/11/2019, 1:22 PMghedeon
11/11/2019, 3:47 PMResult<T>
in Java? All extensions seem to be InlineOnly
, how would you fold this class?ianrumac
11/11/2019, 4:13 PMEllen Spertus
11/11/2019, 6:35 PMwhen
to switch
, but I created this monstrosity in order to combine multiple is
cases. Is there a better way without changing the sealed class ConnectionState
(which I might end up doing)?
if (savedConnectionState is ConnectionState.Isolated) {
view.initializeButtons(true, false)
} else if (savedConnectionState is ConnectionState.Advertising ||
savedConnectionState is ConnectionState.Discovering ||
savedConnectionState is ConnectionState.Initiating ||
savedConnectionState is ConnectionState.Authenticating ||
savedConnectionState is ConnectionState.Connecting) {
view.initializeButtons(false, false)
} else if (savedConnectionState is ConnectionState.ReadyToSend) {
view.initializeButtons(false, true)
} else if (savedConnectionState is ConnectionState.Failure) {
view.initializeButtons(false, false)
}
nwh
11/12/2019, 12:17 AMSee also: [String.toUpperCase(Locale)]
So that overloaded functions can be differentiated?Animesh Sahu
11/12/2019, 5:53 AMKate
11/12/2019, 8:15 AMMani
11/12/2019, 9:20 AMPaul Woitaschek
11/12/2019, 10:28 AMpublic static JsonAdapter<?> create(Class<?> rawType) {
return new SafeEnumJsonAdapter<>((Class<? extends Enum>) rawType).nullSafe();
}
Stephan Schroeder
11/12/2019, 3:27 PMData.Single
but it fails.
sealed class Data<T: Any> {
class Single<T: Any>(val single: T?): Data<T>()
class ListOf<T: Any>(val list: List<T>): Data<T>()
}
Could the reason for the mismatch be that the constructor parameter single
is nullable??
The error message is: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of uk.co.whichdigital.pricingengine.Data$Single
(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value (‘up and running’)
Here is my current jsonMapper config:
private val jsonMapper = ObjectMapper().apply {
registerModule(KotlinModule())
configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
}
UPDATE: I changed the code to `Data.Single`’s generic parameter is nullable class Single<T>(val single: T): Data<T>()
but the error message didn’t change.Oleg Siboglov
11/12/2019, 5:02 PM<T extends LifecycleOwner & ViewModelStoreOwner>
would be?Sandeep Gurram
11/13/2019, 7:25 AMAndreas Unterweger
11/13/2019, 10:33 AMval ibMock = mockkClass(InstalledBase::class)
every { ibMock.getModelDescriptions() } returns emptyList<ModelDescription>()
but it doesnt work. getModelDescriptions() still returns another list. i have no access to the object instaledbase in my test, but i want that getModelDescriptions() always returns an empty listBrian Carbone
11/13/2019, 3:55 PMget() = field.coerceAtLeast(0)
I don't know how to make a delegate to replace thislouiscad
11/13/2019, 4:32 PMFudge
11/13/2019, 8:14 PMKy Leggiero
11/13/2019, 10:54 PMTauhid Rehman
11/14/2019, 2:26 AM.mask
function? basically I need to mask a certain number of integers with a *
ursus
11/14/2019, 5:06 AMMohamed Ibrahim
11/14/2019, 7:03 AMCyberpunk Keanu
11/14/2019, 4:21 PMBen Madore
11/14/2019, 9:09 PMgradle spotlessCheck
i get no issues, but i get a lot when i run ktlint
eekboom
11/14/2019, 10:13 PMtasks.compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
is the same as
tasks.compileKotlin.configure {
kotlinOptions.jvmTarget = "1.8"
}
Can somebody explain to me how this magic works?
compileKotlin
is a property of type TaskProvider<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>
which is an interface with two abstract methods, so it can't be SAM, right?eekboom
11/14/2019, 10:18 PMoperator fun <T> NamedDomainObjectProvider<T>.invoke(action: T.() -> Unit) =
configure(action)
Nice.Akhil Sunny
11/14/2019, 11:00 PMtask iosTest {
def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
dependsOn 'linkTestDebugExecutableIos'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Runs tests for target 'ios' on an iOS simulator"
doLast {
def binary = kotlin.targets.ios.compilations.test.getBinary('EXECUTABLE', 'DEBUG')
def infoPlistSrc = file("$rootProject.projectDir/src/iosTest/resources/Info.plist")
def infoPlistDest = file("$binary.parentFile/Info.plist")
Files.copy(infoPlistSrc.toPath(), infoPlistDest.toPath(), StandardCopyOption.REPLACE_EXISTING)
exec {
commandLine 'export', 'SIMCTL_CHILD_CFNETWORK_DIAGNOSTICS=3'
commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath
}
}
}
- this simulator runs in a terminal and executes the tests. But I can't find any reports generated by it(html/xml ). Is it possible to have reports generated by this simulator ? or is there any other way to generate reports while unit testing a Kotlin iOS output ? . Pls helpbodiam
11/14/2019, 11:23 PMjames
11/14/2019, 11:45 PMit.nullableField
is null. I've tried the following, but it doesn't work as expected because the smart cast fails, as seen in comment:
repo.getThings()
.mapNotNull {
if (it.nullableField != null) {
SomeOtherThing(
id = it.id,
name = it.name,
requiredField = it.nullableField // compiler error: Smart cast to String is impossible because it.nullableField is a public API property declared in a different module
)
} else null
}
james
11/14/2019, 11:45 PMit.nullableField
is null. I've tried the following, but it doesn't work as expected because the smart cast fails, as seen in comment:
repo.getThings()
.mapNotNull {
if (it.nullableField != null) {
SomeOtherThing(
id = it.id,
name = it.name,
requiredField = it.nullableField // compiler error: Smart cast to String is impossible because it.nullableField is a public API property declared in a different module
)
} else null
}
streetsofboston
11/14/2019, 11:48 PM.filter { it.nullableField != null }
into the chain.
Then just do .map { SomeOtherThing( ..., ..., requiredField = it.nullableField!!) }
!!
check; smart-casting won’t work in this casejames
11/14/2019, 11:49 PMit.nullableField
where my comment is.
both of these seem to work, but I'm wondering what the idiomatic way is?filter
feels more readable at leastbasher
11/14/2019, 11:51 PMrepo.getThings()
.mapNotNull { thing ->
thing.nullableField?.let {
SomeOtherThing(
id = thing.id,
name = thing.name,
requiredField = it
)
}
}
james
11/14/2019, 11:58 PMfilter
basher
11/14/2019, 11:58 PMMatteo Mirk
11/19/2019, 12:29 PMfilter
is the best option