Skip to content

Commit 9bfd89d

Browse files
authored
Merge pull request #18 from linked-planet/feature/bump_arrow
Feature/bump arrow/kotlin versions
2 parents 2ded390 + fffa5d2 commit 9bfd89d

File tree

24 files changed

+49
-43
lines changed

24 files changed

+49
-43
lines changed

kotlin-insight-client/kotlin-insight-client-api/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,11 @@
3939
<artifactId>kotlin-atlassian-client-core-common</artifactId>
4040
<version>${project.version}</version>
4141
</dependency>
42+
<dependency>
43+
<groupId>org.jetbrains.kotlin</groupId>
44+
<artifactId>kotlin-reflect</artifactId>
45+
<version>${kotlin.version}</version>
46+
<scope>compile</scope>
47+
</dependency>
4248
</dependencies>
4349
</project>

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/impl/AbstractInsightObjectRepository.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
package com.linkedplanet.kotlininsightclient.api.impl
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
24-
import arrow.core.rightIfNotNull
23+
import arrow.core.left
24+
import arrow.core.raise.either
25+
import arrow.core.right
2526
import com.linkedplanet.kotlinatlassianclientcore.common.api.Page
2627
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError
2728
import com.linkedplanet.kotlininsightclient.api.error.OtherNotFoundError
@@ -57,9 +58,8 @@ abstract class AbstractInsightObjectRepository<DomainType> : InsightObjectReposi
5758
}
5859

5960
override suspend fun update(domainObject: DomainType): Either<InsightClientError, DomainType> = either {
60-
val insightObject = loadExistingInsightObject(domainObject).bind().rightIfNotNull {
61-
OtherNotFoundError("Could not loadExistingInsightObject for DomainObject:$domainObject.")
62-
}.bind()
61+
val insightObject = (loadExistingInsightObject(domainObject).bind()?.right()
62+
?: OtherNotFoundError("Could not loadExistingInsightObject for DomainObject:$domainObject.").left()).bind()
6363
val attributes: List<InsightAttribute> = attributesFromDomain(domainObject).bind()
6464
val insightObjectWithAttributes = insightObject.copy(attributes = attributes)
6565
val updatedObject = insightObjectOperator.updateInsightObject(insightObjectWithAttributes).bind()

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/impl/AbstractNameMappedRepository.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlininsightclient.api.impl
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import arrow.core.right
2525
import arrow.core.sequenceEither
2626
import com.linkedplanet.kotlinatlassianclientcore.common.error.asEither
@@ -39,7 +39,6 @@ import com.linkedplanet.kotlininsightclient.api.model.ObjectTypeSchema
3939
import com.linkedplanet.kotlininsightclient.api.model.ObjectTypeSchemaAttribute
4040
import com.linkedplanet.kotlininsightclient.api.model.getAttribute
4141
import com.linkedplanet.kotlininsightclient.api.model.isValueAttribute
42-
import jdk.jfr.Experimental
4342
import kotlinx.coroutines.runBlocking
4443
import java.time.ZonedDateTime
4544
import kotlin.reflect.KClass
@@ -58,7 +57,7 @@ import kotlin.reflect.full.primaryConstructor
5857
* idea: class to id map (for automatic child object parsing)
5958
* optional: attribute name to id map in case one wants to manually specify everything
6059
*/
61-
@Experimental
60+
//@Experimental
6261
abstract class AbstractNameMappedRepository<DomainType : Any>(
6362
private val klass: KClass<DomainType>
6463
) : AbstractInsightObjectRepository<DomainType>() {
@@ -68,7 +67,7 @@ abstract class AbstractNameMappedRepository<DomainType : Any>(
6867
override var RESULTS_PER_PAGE: Int = Int.MAX_VALUE
6968
override val objectTypeId: InsightObjectTypeId get() = objectTypeSchema.id
7069
@Suppress("MemberVisibilityCanBePrivate") // this is public, so clients could use it to add missing functionality
71-
protected val objectTypeSchema: ObjectTypeSchema by lazy { objectTypeSchemaFromKClass().orNull()!! }
70+
protected val objectTypeSchema: ObjectTypeSchema by lazy { objectTypeSchemaFromKClass().getOrNull()!! }
7271

7372
private val props: Collection<KProperty1<DomainType, *>> = klass.memberProperties
7473
private val attrsMap: Map<String, ObjectTypeSchemaAttribute> by lazy {

kotlin-insight-client/kotlin-insight-client-http/src/main/kotlin/com/linkedplanet/kotlininsightclient/http/HttpInsightAttachmentOperator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlininsightclient.http
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import com.google.gson.reflect.TypeToken
2525
import com.linkedplanet.kotlinatlassianclientcore.common.error.asEither
2626
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError

kotlin-insight-client/kotlin-insight-client-http/src/main/kotlin/com/linkedplanet/kotlininsightclient/http/HttpInsightObjectOperator.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
package com.linkedplanet.kotlininsightclient.http
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import arrow.core.flatten
25-
import arrow.core.rightIfNotNull
25+
import arrow.core.left
26+
import arrow.core.right
2627
import com.google.gson.JsonParser
2728
import com.linkedplanet.kotlinatlassianclientcore.common.api.JiraUser
2829
import com.linkedplanet.kotlinhttpclient.api.http.GSON
@@ -150,8 +151,8 @@ class HttpInsightObjectOperator(private val context: HttpInsightClientContext) :
150151
vararg insightAttributes: InsightAttribute,
151152
toDomain: MapToDomain<T>
152153
): Either<InsightClientError, T> = either {
153-
val obj = getObjectById(objectId, ::identity).bind()
154-
.rightIfNotNull { ObjectNotFoundError(objectId) }.bind()
154+
val obj = (getObjectById(objectId, ::identity).bind()
155+
?.right() ?: ObjectNotFoundError(objectId).left()).bind()
155156

156157
val attributeMap = obj.attributes.associateBy { it.attributeId }.toMutableMap()
157158
insightAttributes.forEach {
@@ -201,8 +202,8 @@ class HttpInsightObjectOperator(private val context: HttpInsightClientContext) :
201202
toDomain: MapToDomain<T>
202203
): Either<InsightClientError, T> = either {
203204
val insightObjectId = createInsightObject(objectTypeId, *insightAttributes).bind()
204-
getObjectById(insightObjectId, toDomain).bind()
205-
.rightIfNotNull { ObjectNotFoundError(insightObjectId) }.bind()
205+
(getObjectById(insightObjectId, toDomain).bind()
206+
?.right() ?: ObjectNotFoundError(insightObjectId).left()).bind()
206207
}
207208

208209
// PRIVATE DOWN HERE

kotlin-insight-client/kotlin-insight-client-http/src/main/kotlin/com/linkedplanet/kotlininsightclient/http/HttpInsightObjectTypeOperator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlininsightclient.http
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import com.google.gson.reflect.TypeToken
2525
import com.linkedplanet.kotlinatlassianclientcore.common.error.asEither
2626
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError

kotlin-insight-client/kotlin-insight-client-sdk/src/main/kotlin/com/linkedplanet/kotlininsightclient/sdk/SdkInsightAttachmentOperator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlininsightclient.sdk
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType
2525
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError
2626
import com.linkedplanet.kotlininsightclient.api.interfaces.InsightAttachmentOperator

kotlin-insight-client/kotlin-insight-client-sdk/src/main/kotlin/com/linkedplanet/kotlininsightclient/sdk/SdkInsightObjectOperator.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
package com.linkedplanet.kotlininsightclient.sdk
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import arrow.core.flatMap
2525
import arrow.core.left
2626
import arrow.core.right
27-
import arrow.core.rightIfNotNull
2827
import com.atlassian.jira.component.ComponentAccessor
2928
import com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType
3029
import com.atlassian.jira.config.properties.ApplicationProperties
@@ -185,8 +184,8 @@ object SdkInsightObjectOperator : InsightObjectOperator {
185184
toDomain: MapToDomain<T>
186185
): Either<InsightClientError, T> =
187186
either {
188-
val obj = getObjectById(objectId, ::identity).bind()
189-
.rightIfNotNull { ObjectNotFoundError(objectId) }.bind()
187+
val obj = (getObjectById(objectId, ::identity).bind()
188+
?.right() ?: ObjectNotFoundError(objectId).left<ObjectNotFoundError>()).bind()
190189
val updated = updateObject(obj, *insightAttributes).bind()
191190
toDomain(updated).bind()
192191
}
@@ -269,8 +268,8 @@ object SdkInsightObjectOperator : InsightObjectOperator {
269268
toDomain: MapToDomain<T>
270269
): Either<InsightClientError, T> = either {
271270
val insightObjectId = createInsightObject(objectTypeId, *insightAttributes).bind()
272-
getObjectById(insightObjectId, toDomain).bind()
273-
.rightIfNotNull { ObjectNotFoundError(insightObjectId) }.bind()
271+
(getObjectById(insightObjectId, toDomain).bind()
272+
?.right() ?: ObjectNotFoundError(insightObjectId).left<ObjectNotFoundError>()).bind()
274273
}
275274

276275
private fun createEmptyDomainObject(

kotlin-insight-client/kotlin-insight-client-test-base/src/main/kotlin/com/linkedplanet/kotlininsightclient/repositories/CompanyTestRepositoryBasedOnAbstractImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlininsightclient.repositories
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import com.linkedplanet.kotlininsightclient.Company
2525
import com.linkedplanet.kotlininsightclient.InsightObjectType
2626
import com.linkedplanet.kotlininsightclient.TestAttributes

kotlin-insight-client/kotlin-insight-client-test-base/src/main/kotlin/com/linkedplanet/kotlininsightclient/repositories/CompanyTestRepositoryManualImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlininsightclient.repositories
2121

2222
import arrow.core.Either
23-
import arrow.core.computations.either
23+
import arrow.core.raise.either
2424
import arrow.core.right
2525
import com.linkedplanet.kotlininsightclient.Company
2626
import com.linkedplanet.kotlininsightclient.InsightObjectType
@@ -50,7 +50,7 @@ class CompanyTestRepositoryManualImpl(
5050

5151
private suspend fun toDomain(insightObject: InsightObject) = Company(
5252
name = insightObject.getStringValue(name)!!,
53-
country = countryTestRepositoryManualImpl.getById(insightObject.getSingleReferenceValue(countryRef)!!.objectId).orNull()!!,
53+
country = countryTestRepositoryManualImpl.getById(insightObject.getSingleReferenceValue(countryRef)!!.objectId).getOrNull()!!,
5454
).right()
5555

5656
override suspend fun create(domainObject: Company): Either<InsightClientError, Company> = either {

0 commit comments

Comments
 (0)