Skip to content

Commit

Permalink
ktlintFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Jul 11, 2024
1 parent 061ee7d commit febe4e7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package aws.smithy.kotlin.runtime.awsprotocol.rpcv2.cbor

import aws.smithy.kotlin.runtime.ClientException
import aws.smithy.kotlin.runtime.InternalApi
import aws.smithy.kotlin.runtime.ServiceException
import aws.smithy.kotlin.runtime.client.ProtocolResponseInterceptorContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package aws.smithy.kotlin.runtime.awsprotocol.rpcv2.cbor

import aws.smithy.kotlin.runtime.ClientException
import aws.smithy.kotlin.runtime.ServiceException
import aws.smithy.kotlin.runtime.http.*
import aws.smithy.kotlin.runtime.http.operation.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ package aws.smithy.kotlin.runtime.content
* A floating point decimal number with arbitrary precision.
* @param value the [String] representation of this decimal number
*/
public expect class BigDecimal(value: String) : Number, Comparable<BigDecimal> {
public expect class BigDecimal(value: String) :
Number,
Comparable<BigDecimal> {
/**
* Create an instance of [BigDecimal] from a mantissa and exponent.
* @param mantissa a [BigInteger] representing the mantissa of this big decimal
Expand Down Expand Up @@ -37,4 +39,4 @@ public expect class BigDecimal(value: String) : Number, Comparable<BigDecimal> {
public fun toPlainString(): String
override fun equals(other: Any?): Boolean
public override operator fun compareTo(other: BigDecimal): Int
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ package aws.smithy.kotlin.runtime.content
* An arbitrarily large signed integer
* @param value the string representation of this large integer
*/
public expect class BigInteger(value: String) : Number, Comparable<BigInteger> {
public expect class BigInteger(value: String) :
Number,
Comparable<BigInteger> {
/**
* Create an instance of [BigInteger] from a [ByteArray]
* @param bytes ByteArray representing the large integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
*/
package aws.smithy.kotlin.runtime.content

public actual class BigDecimal actual constructor(public val value: String) : Number(), Comparable<BigDecimal> {
public actual class BigDecimal actual constructor(public val value: String) :
Number(),
Comparable<BigDecimal> {
private val delegate = java.math.BigDecimal(value)

public actual constructor(mantissa: BigInteger, exponent: Int) : this(
java.math.BigDecimal(
java.math.BigInteger(mantissa.toString()),
exponent
).toPlainString()
exponent,
).toPlainString(),
)

public actual fun toPlainString(): String = delegate.toPlainString()
Expand All @@ -31,4 +33,4 @@ public actual class BigDecimal actual constructor(public val value: String) : Nu
get() = delegate.scale()

actual override fun compareTo(other: BigDecimal): Int = delegate.compareTo(other.delegate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
*/
package aws.smithy.kotlin.runtime.content

public actual class BigInteger actual constructor(public val value: String) : Number(), Comparable<BigInteger> {
public actual class BigInteger actual constructor(public val value: String) :
Number(),
Comparable<BigInteger> {
private val delegate = java.math.BigInteger(value)

public actual constructor(bytes: ByteArray) : this(java.math.BigInteger(bytes).toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package aws.smithy.kotlin.runtime.serde.cbor.encoding

import aws.smithy.kotlin.runtime.io.*
import aws.smithy.kotlin.runtime.serde.DeserializationException
import aws.smithy.kotlin.runtime.serde.cbor.encodeArgument
import aws.smithy.kotlin.runtime.serde.cbor.encodeMajorMinor

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,18 @@ internal class DecimalFraction(val value: BigDecimal) : Value {

val (exponentValue, mantissaValue) = list

val mantissa = when(mantissaValue) {
val mantissa = when (mantissaValue) {
is UInt -> BigInteger(mantissaValue.value.toString())
is NegInt -> BigInteger("-" + mantissaValue.value.toString())
is Tag -> when(mantissaValue.value) {
is Tag -> when (mantissaValue.value) {
is NegBigNum -> mantissaValue.value.value
is BigNum -> mantissaValue.value.value
else -> throw DeserializationException("Expected BigNum or NegBigNum for CBOR tagged decimal fraction mantissa, got ${mantissaValue.id}")
}
else -> throw DeserializationException("Expected UInt, NegInt, or Tag for CBOR decimal fraction mantissa, got $mantissaValue")
}

val exponent = when(exponentValue) {
val exponent = when (exponentValue) {
is UInt -> exponentValue.value.toInt()
is NegInt -> -exponentValue.value.toInt()
else -> throw DeserializationException("Expected integer for CBOR decimal fraction exponent value, got $exponentValue.")
Expand Down

0 comments on commit febe4e7

Please sign in to comment.