Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
popematt committed Apr 29, 2024
1 parent 1c45280 commit feeea7b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 39 deletions.
3 changes: 1 addition & 2 deletions src/main/kotlin/com/amazon/ionelement/api/Equivalence.kt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ internal fun hashIonValue(ionValue: IonValue): Int {
}
// Adding compareTo(0.0) causes 0e0 to have a different hash code than -0e0
IonType.FLOAT -> (ionValue as IonFloat).doubleValue().let { it.compareTo(0.0).hashCode() * 31 + it.hashCode() }
IonType.DECIMAL -> (ionValue as IonDecimal).decimalValue().let { it.isNegativeZero.hashCode() * 31 + it.hashCode() }
IonType.DECIMAL -> (ionValue as IonDecimal).decimalValue().let { it.isNegativeZero.hashCode() * 31 + it.hashCode() }
IonType.TIMESTAMP -> (ionValue as IonTimestamp).timestampValue().hashCode()
IonType.STRING -> (ionValue as IonString).stringValue().hashCode()
IonType.SYMBOL -> (ionValue as IonSymbol).symbolValue().hashCode()
Expand All @@ -245,7 +245,6 @@ internal fun hashIonValue(ionValue: IonValue): Int {
return typeAndValueHashCode * 31 + ionValue.typeAnnotationSymbols.toList().hashCode()
}


/**
* Calculates the hash code of a [StructField].
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class IonElementConstraintException internal constructor(
* [blame] is the [IonValue] instance that violates the constraint.
*/
public class IonElementWrapperException internal constructor(
public val blame: IonValue, // TODO: Is this a good idea?
public val blame: IonValue, // TODO: Is this a good idea?
description: String,
cause: Throwable? = null
) : IonElementException(null, description, cause)
24 changes: 12 additions & 12 deletions src/main/kotlin/com/amazon/ionelement/impl/UnionElements.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.amazon.ionelement.api.*

// Macros or smarter type bounds would be nice here.

internal interface UnionOfBoolAndAnyElement: BoolElement, AnyElement {
internal interface UnionOfBoolAndAnyElement : BoolElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfBoolAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfBoolAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfBoolAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -14,7 +14,7 @@ internal interface UnionOfBoolAndAnyElement: BoolElement, AnyElement {
override fun withoutMetas(): UnionOfBoolAndAnyElement = _withoutMetas()
}

internal interface UnionOfIntAndAnyElement: IntElement, AnyElement {
internal interface UnionOfIntAndAnyElement : IntElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfIntAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfIntAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfIntAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -24,7 +24,7 @@ internal interface UnionOfIntAndAnyElement: IntElement, AnyElement {
override fun withoutMetas(): UnionOfIntAndAnyElement = _withoutMetas()
}

internal interface UnionOfFloatAndAnyElement: FloatElement, AnyElement {
internal interface UnionOfFloatAndAnyElement : FloatElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfFloatAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfFloatAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfFloatAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -34,7 +34,7 @@ internal interface UnionOfFloatAndAnyElement: FloatElement, AnyElement {
override fun withoutMetas(): UnionOfFloatAndAnyElement = _withoutMetas()
}

internal interface UnionOfDecimalAndAnyElement: DecimalElement, AnyElement {
internal interface UnionOfDecimalAndAnyElement : DecimalElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfDecimalAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfDecimalAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfDecimalAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -44,7 +44,7 @@ internal interface UnionOfDecimalAndAnyElement: DecimalElement, AnyElement {
override fun withoutMetas(): UnionOfDecimalAndAnyElement = _withoutMetas()
}

internal interface UnionOfTimestampAndAnyElement: TimestampElement, AnyElement {
internal interface UnionOfTimestampAndAnyElement : TimestampElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfTimestampAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfTimestampAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfTimestampAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -54,7 +54,7 @@ internal interface UnionOfTimestampAndAnyElement: TimestampElement, AnyElement {
override fun withoutMetas(): UnionOfTimestampAndAnyElement = _withoutMetas()
}

internal interface UnionOfStringAndAnyElement: StringElement, AnyElement {
internal interface UnionOfStringAndAnyElement : StringElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfStringAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfStringAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfStringAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -64,7 +64,7 @@ internal interface UnionOfStringAndAnyElement: StringElement, AnyElement {
override fun withoutMetas(): UnionOfStringAndAnyElement = _withoutMetas()
}

internal interface UnionOfSymbolAndAnyElement: SymbolElement, AnyElement {
internal interface UnionOfSymbolAndAnyElement : SymbolElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfSymbolAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfSymbolAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfSymbolAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -74,7 +74,7 @@ internal interface UnionOfSymbolAndAnyElement: SymbolElement, AnyElement {
override fun withoutMetas(): UnionOfSymbolAndAnyElement = _withoutMetas()
}

internal interface UnionOfBlobAndAnyElement: BlobElement, AnyElement {
internal interface UnionOfBlobAndAnyElement : BlobElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfBlobAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfBlobAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfBlobAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -84,7 +84,7 @@ internal interface UnionOfBlobAndAnyElement: BlobElement, AnyElement {
override fun withoutMetas(): UnionOfBlobAndAnyElement = _withoutMetas()
}

internal interface UnionOfClobAndAnyElement: ClobElement, AnyElement {
internal interface UnionOfClobAndAnyElement : ClobElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfClobAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfClobAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfClobAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -94,7 +94,7 @@ internal interface UnionOfClobAndAnyElement: ClobElement, AnyElement {
override fun withoutMetas(): UnionOfClobAndAnyElement = _withoutMetas()
}

internal interface UnionOfListAndAnyElement: ListElement, AnyElement {
internal interface UnionOfListAndAnyElement : ListElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfListAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfListAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfListAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -104,7 +104,7 @@ internal interface UnionOfListAndAnyElement: ListElement, AnyElement {
override fun withoutMetas(): UnionOfListAndAnyElement = _withoutMetas()
}

internal interface UnionOfSexpAndAnyElement: SexpElement, AnyElement {
internal interface UnionOfSexpAndAnyElement : SexpElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfSexpAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfSexpAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfSexpAndAnyElement = _withAnnotations(additionalAnnotations)
Expand All @@ -114,7 +114,7 @@ internal interface UnionOfSexpAndAnyElement: SexpElement, AnyElement {
override fun withoutMetas(): UnionOfSexpAndAnyElement = _withoutMetas()
}

internal interface UnionOfStructAndAnyElement: StructElement, AnyElement {
internal interface UnionOfStructAndAnyElement : StructElement, AnyElement {
override fun copy(annotations: List<String>, metas: MetaContainer): UnionOfStructAndAnyElement
override fun withAnnotations(vararg additionalAnnotations: String): UnionOfStructAndAnyElement = _withAnnotations(*additionalAnnotations)
override fun withAnnotations(additionalAnnotations: Iterable<String>): UnionOfStructAndAnyElement = _withAnnotations(additionalAnnotations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import com.amazon.ion.IonSexp
import com.amazon.ionelement.api.*
import com.amazon.ionelement.impl.*
import com.amazon.ionelement.impl.SexpElementImpl
import com.amazon.ionelement.impl._withAnnotations
import com.amazon.ionelement.impl._withMeta
import com.amazon.ionelement.impl._withMetas
import com.amazon.ionelement.impl._withoutAnnotations
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import com.amazon.ionelement.api.*
import com.amazon.ionelement.impl.*
import com.amazon.ionelement.impl.MutableStructFieldsImpl
import com.amazon.ionelement.impl.StructElementImpl
import com.amazon.ionelement.impl._withAnnotations
import com.amazon.ionelement.impl._withMeta
import com.amazon.ionelement.impl._withMetas
import com.amazon.ionelement.impl._withoutAnnotations
import java.util.function.Consumer
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.PersistentMap
Expand Down
26 changes: 13 additions & 13 deletions src/test/kotlin/com/amazon/ionelement/EquivTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,20 @@ data class EquivTestCase(val left: String, val right: String, val isEquiv: Boole
private fun IonElement.createProxy(): AnyElement {
this as AnyElement
return if (isNull) {
object: AnyElement by this {}
object : AnyElement by this {}
} else when (this) {
is UnionOfBoolAndAnyElement -> object: UnionOfBoolAndAnyElement by this {}
is UnionOfIntAndAnyElement -> object: UnionOfIntAndAnyElement by this {}
is UnionOfFloatAndAnyElement -> object: UnionOfFloatAndAnyElement by this {}
is UnionOfDecimalAndAnyElement -> object: UnionOfDecimalAndAnyElement by this {}
is UnionOfTimestampAndAnyElement -> object: UnionOfTimestampAndAnyElement by this {}
is UnionOfStringAndAnyElement -> object: UnionOfStringAndAnyElement by this {}
is UnionOfSymbolAndAnyElement -> object: UnionOfSymbolAndAnyElement by this {}
is UnionOfBlobAndAnyElement -> object: UnionOfBlobAndAnyElement by this {}
is UnionOfClobAndAnyElement -> object: UnionOfClobAndAnyElement by this {}
is UnionOfListAndAnyElement -> object: UnionOfListAndAnyElement by this {}
is UnionOfSexpAndAnyElement -> object: UnionOfSexpAndAnyElement by this {}
is UnionOfStructAndAnyElement -> object: UnionOfStructAndAnyElement by this {}
is UnionOfBoolAndAnyElement -> object : UnionOfBoolAndAnyElement by this {}
is UnionOfIntAndAnyElement -> object : UnionOfIntAndAnyElement by this {}
is UnionOfFloatAndAnyElement -> object : UnionOfFloatAndAnyElement by this {}
is UnionOfDecimalAndAnyElement -> object : UnionOfDecimalAndAnyElement by this {}
is UnionOfTimestampAndAnyElement -> object : UnionOfTimestampAndAnyElement by this {}
is UnionOfStringAndAnyElement -> object : UnionOfStringAndAnyElement by this {}
is UnionOfSymbolAndAnyElement -> object : UnionOfSymbolAndAnyElement by this {}
is UnionOfBlobAndAnyElement -> object : UnionOfBlobAndAnyElement by this {}
is UnionOfClobAndAnyElement -> object : UnionOfClobAndAnyElement by this {}
is UnionOfListAndAnyElement -> object : UnionOfListAndAnyElement by this {}
is UnionOfSexpAndAnyElement -> object : UnionOfSexpAndAnyElement by this {}
is UnionOfStructAndAnyElement -> object : UnionOfStructAndAnyElement by this {}
else -> TODO("Unreachable")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class IonValueInteroperability {
set("odds", oddList)
}


// These verifications rely on non-public functionality

// The outer struct has been seamlessly converted to `StructElement`
Expand All @@ -68,5 +67,4 @@ class IonValueInteroperability {
// ... but we're still using the wrapped IonValue for the evens list.
assertSame(ionValueEvens.get("evens"), (evensAndOdds["evens"] as IonValueWrapper).unwrap())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class IonValueWrapperTests {
}
}


@ParameterizedTest
@EnumSource
fun GoodTestCase.`wrapUncheckedIntoIonElement should wrap the same instance, not a copy`() = testIt {
Expand Down

0 comments on commit feeea7b

Please sign in to comment.