From 1358b58ed6d7010ec26395e3d49d437b9ea7ae47 Mon Sep 17 00:00:00 2001 From: Johan Haleby Date: Fri, 1 Nov 2024 14:04:17 +0100 Subject: [PATCH] Implemented "isIn" kotlin extension --- changelog.md | 2 +- common/filter/pom.xml | 54 ++++++++++++++++++- .../condition/ConditionExtensions.kt | 21 ++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 common/filter/src/main/kotlin/org/occurrent/condition/ConditionExtensions.kt diff --git a/changelog.md b/changelog.md index c6c04542d..5bc6878c6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ ### Next version -* Implemented "in" conditions so you can now do e.g. `subscriptionModel.subscribe("id", OccurrentSubscriptionFilter.filter(Filter.streamVersion(Condition.in(12L, 14L))` +* Implemented "in" conditions so you can now do e.g. `subscriptionModel.subscribe("id", OccurrentSubscriptionFilter.filter(Filter.streamVersion(Condition.in(12L, 14L))`. There's also a Kotlin extension function, `isIn`, which can be imported from `org.occurrent.condition.isIn`. ### 0.19.6 (2024-10-11) * Fixed so that inserting events with "any" WriteCondition never fails even if more than two threads are writing events to the same stream at the same time. (Fixed in MongoEventStore and SpringMongoEventStore) diff --git a/common/filter/pom.xml b/common/filter/pom.xml index 05f31a0eb..0da82e808 100644 --- a/common/filter/pom.xml +++ b/common/filter/pom.xml @@ -15,7 +15,8 @@ ~ limitations under the License. --> - + common org.occurrent @@ -26,6 +27,11 @@ filter + + org.jetbrains.kotlin + kotlin-stdlib + true + org.occurrent cloudevents-extension @@ -33,5 +39,51 @@ + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + process-sources + + compile + + + + src/main/java + src/main/kotlin + src/main/resources + + + + + test-compile + test-compile + + test-compile + + + + src/test/java + src/test/kotlin + src/test/resources + + + + + + + -Xjsr305=strict + + 17 + + + + + \ No newline at end of file diff --git a/common/filter/src/main/kotlin/org/occurrent/condition/ConditionExtensions.kt b/common/filter/src/main/kotlin/org/occurrent/condition/ConditionExtensions.kt new file mode 100644 index 000000000..d23671f69 --- /dev/null +++ b/common/filter/src/main/kotlin/org/occurrent/condition/ConditionExtensions.kt @@ -0,0 +1,21 @@ +/* + * + * Copyright 2024 Johan Haleby + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.occurrent.condition + +fun isIn(values: Collection): Condition = Condition.`in`(values) +fun isIn(value: T, vararg moreValues: T): Condition = Condition.`in`(value, *moreValues) \ No newline at end of file