This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified T> String.asJson() = | |
jacksonObjectMapper().readValue<T>(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NotNull | |
public static final String getParsableNumber(@NotNull String number) { | |
Intrinsics.checkParameterIsNotNull(number, "number"); | |
return ParsableNumber.constructor_impl(number); | |
} | |
public static final void main() { | |
String parsableNumber = getParsableNumber("100.12212"); | |
BigDecimal var1 = ParsableNumber.getParsed_impl(parsableNumber); | |
System.out.println(var1); | |
System.out.println(parsableNumber); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class ParsableNumber { | |
@NotNull | |
private final String original; | |
@NotNull | |
public final String getOriginal() { return this.original; } | |
// $FF: synthetic method | |
private ParsableNumber(@NotNull String original) { | |
Intrinsics.checkParameterIsNotNull(original, "original"); | |
super(); | |
this.original = original; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JvmInline | |
value class ParsableNumber(val original: String) { | |
val parsed: BigDecimal | |
get() = original.toBigDecimal().setScale(2, RoundingMode.HALF_UP) | |
} | |
fun getParsableNumber(number: String): ParsableNumber { | |
return ParsableNumber(number) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* parses string number into BigDecimal with a scale of 2 | |
*/ | |
fun parseNumber(number: String): BigDecimal { | |
return number.toBigDecimal().setScale(2, RoundingMode.HALF_UP) | |
} | |
fun main() { | |
println(parseNumber("100.12212")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JvmInline | |
value class Password(val value: String) | |
@JvmInline | |
value class UserName(val value: String) | |
fun auth(userName: UserName, password: Password) { | |
println("authenticating $userName.") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun auth(userName: String, password: String) { | |
println("authenticating $userName.") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JvmName("takeWrappedInt") | |
fun take(w: WrappedInt) { | |
println(w.value) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JvmInline | |
value class WrappedInt(val value: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> countOccurrences(values: Collection<T>): Map<T, Int> = | |
values.groupingBy { it }.eachCount() |