Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 2bbcc1a

Browse files
committed
refactor: renamed project to PED
1 parent 712d70b commit 2bbcc1a

17 files changed

Lines changed: 71 additions & 92 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Kotlin Partial Encoding Decoding (KPED) [![](https://jitpack.io/v/org.cufy/kped.svg)](https://jitpack.io/#org.cufy/kped)
1+
# Partial Encoding / Decoding (PED) [![](https://jitpack.io/v/org.cufy/ped.svg)](https://jitpack.io/#org.cufy/ped)
22

33
Serialization Extensions and Serializers for enhancing partial encoding and decoding
44
that uses no object mapping.
@@ -17,9 +17,9 @@ repositories {
1717

1818
dependencies {
1919
// Replace TAG with the desired version
20-
implementation("org.cufy.kped:bson:TAG")
21-
implementation("org.cufy.kped:json:TAG")
22-
implementation("org.cufy.kped:kped-core:TAG")
23-
implementation("org.cufy.kped:kped-bson:TAG")
20+
implementation("org.cufy.ped:bson:TAG")
21+
implementation("org.cufy.ped:json:TAG")
22+
implementation("org.cufy.ped:ped-core:TAG")
23+
implementation("org.cufy.ped:ped-bson:TAG")
2424
}
2525
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ kotlin {
1313
commonMain {
1414
dependencies {
1515
implementation(project(":bson"))
16-
implementation(project(":kped-core"))
16+
implementation(project(":ped-core"))
1717

1818
implementation(kotlin("stdlib"))
1919
implementation(libs.kotlin.serialization.json)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.cufy.kped
16+
package org.cufy.ped
1717

1818
import kotlinx.datetime.Instant
1919
import org.cufy.bson.*

kped-bson/src/commonMain/kotlin/BsonCodecs.kt renamed to ped-bson/src/commonMain/kotlin/BsonCodecs.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.cufy.kped
16+
package org.cufy.ped
1717

1818
import kotlinx.datetime.Instant
1919
import org.cufy.bson.*
@@ -90,7 +90,7 @@ val <I, O : BsonElement> BsonFieldCodec<I, O>.Nullable: BsonFieldCodec<I?, BsonE
9090
* @since 2.0.0
9191
*/
9292
@JvmName("decodeInfixNullish")
93-
@KpedMarker1
93+
@KpedMarker4
9494
infix fun <I, O : BsonElement> O?.decode(codec: BsonNullableCodec<I, O>): I? {
9595
return decode(this, codec)
9696
}
@@ -105,7 +105,7 @@ infix fun <I, O : BsonElement> O?.decode(codec: BsonNullableCodec<I, O>): I? {
105105
* @since 2.0.0
106106
*/
107107
@JvmName("decodeInfixNullable")
108-
@KpedMarker1
108+
@KpedMarker4
109109
infix fun <I, O : BsonElement> O.decode(codec: BsonNullableCodec<I, O>): I? {
110110
return decode(this, codec)
111111
}
@@ -119,7 +119,7 @@ infix fun <I, O : BsonElement> O.decode(codec: BsonNullableCodec<I, O>): I? {
119119
* @since 2.0.0
120120
*/
121121
@JvmName("tryDecodeNullish")
122-
@KpedMarker0
122+
@KpedMarker3
123123
fun <I, O : BsonElement> tryDecode(value: O?, codec: BsonNullableCodec<I, O>): Result<I?> {
124124
return tryDecodeAny(value, codec)
125125
}
@@ -133,7 +133,7 @@ fun <I, O : BsonElement> tryDecode(value: O?, codec: BsonNullableCodec<I, O>): R
133133
* @since 2.0.0
134134
*/
135135
@JvmName("tryDecodeNullable")
136-
@KpedMarker0
136+
@KpedMarker3
137137
fun <I, O : BsonElement> tryDecode(value: O, codec: BsonNullableCodec<I, O>): Result<I?> {
138138
return tryDecodeAny(value, codec)
139139
}
@@ -148,7 +148,7 @@ fun <I, O : BsonElement> tryDecode(value: O, codec: BsonNullableCodec<I, O>): Re
148148
* @since 2.0.0
149149
*/
150150
@JvmName("decodeNullish")
151-
@KpedMarker0
151+
@KpedMarker3
152152
fun <I, O : BsonElement> decode(value: O?, codec: BsonNullableCodec<I, O>): I? {
153153
return decodeAny(value, codec)
154154
}
@@ -163,7 +163,7 @@ fun <I, O : BsonElement> decode(value: O?, codec: BsonNullableCodec<I, O>): I? {
163163
* @since 2.0.0
164164
*/
165165
@JvmName("decodeNullable")
166-
@KpedMarker0
166+
@KpedMarker3
167167
fun <I, O : BsonElement> decode(value: O, codec: BsonNullableCodec<I, O>): I? {
168168
return decodeAny(value, codec)
169169
}

kped-bson/src/commonMain/kotlin/BsonFieldCodec.kt renamed to ped-bson/src/commonMain/kotlin/BsonFieldCodec.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.cufy.kped
16+
package org.cufy.ped
1717

1818
import org.cufy.bson.BsonDocumentLike
1919
import org.cufy.bson.BsonElement
@@ -75,7 +75,7 @@ fun <I, O : BsonElement> FieldCodec(name: String, codec: Codec<I, O>): BsonField
7575
* Return a field codec derived from this one with
7676
* its name tagged with the given language [tag].
7777
*/
78-
@KpedMarker1
78+
@KpedMarker4
7979
infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.lang(tag: String): BsonFieldCodec<I, O> {
8080
if (tag.isEmpty()) return this
8181
return FieldCodec("$name#$tag", this)
@@ -85,7 +85,7 @@ infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.lang(tag: String): BsonField
8585
* Create a new field codec with the given [name]
8686
* and backed by [this] codec.
8787
*/
88-
@KpedMarker1
88+
@KpedMarker4
8989
infix fun <I, O : BsonElement> Codec<I, O>.at(name: String): BsonFieldCodec<I, O> {
9090
return FieldCodec(name, this)
9191
}
@@ -103,7 +103,7 @@ infix fun <I, O : BsonElement> Codec<I, O>.at(name: String): BsonFieldCodec<I, O
103103
* }
104104
* ```
105105
*/
106-
@KpedMarker1
106+
@KpedMarker4
107107
infix fun <I, O : BsonElement> String.be(codec: Codec<I, O>): BsonFieldCodec<I, O> {
108108
return FieldCodec(this, codec)
109109
}
@@ -112,7 +112,7 @@ infix fun <I, O : BsonElement> String.be(codec: Codec<I, O>): BsonFieldCodec<I,
112112
* Return a new codec backed by this codec that returns the given [defaultValue] when decoding fails.
113113
*/
114114
@OptIn(ExperimentalKpedApi::class)
115-
@KpedMarker1
115+
@KpedMarker4
116116
infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.defaultIn(defaultValue: I): BsonFieldCodec<I, O> {
117117
val codec = this as Codec<I, O>
118118
return BsonFieldCodec(name, codec defaultIn defaultValue)
@@ -122,7 +122,7 @@ infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.defaultIn(defaultValue: I):
122122
* Return a new codec backed by this codec that returns the result of invoking the given [block] when decoding fails.
123123
*/
124124
@OptIn(ExperimentalKpedApi::class)
125-
@KpedMarker1
125+
@KpedMarker4
126126
infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.catchIn(block: (Throwable) -> I): BsonFieldCodec<I, O> {
127127
val codec = this as Codec<I, O>
128128
return BsonFieldCodec(name, codec catchIn block)
@@ -132,7 +132,7 @@ infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.catchIn(block: (Throwable) -
132132
* Return a new codec backed by this codec that returns the given [defaultValue] when encoding fails.
133133
*/
134134
@OptIn(ExperimentalKpedApi::class)
135-
@KpedMarker1
135+
@KpedMarker4
136136
infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.defaultOut(defaultValue: O): BsonFieldCodec<I, O> {
137137
val codec = this as Codec<I, O>
138138
return BsonFieldCodec(name, codec defaultOut defaultValue)
@@ -142,7 +142,7 @@ infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.defaultOut(defaultValue: O):
142142
* Return a new codec backed by this codec that returns the result of invoking the given [block] when encoding fails.
143143
*/
144144
@OptIn(ExperimentalKpedApi::class)
145-
@KpedMarker1
145+
@KpedMarker4
146146
infix fun <I, O : BsonElement> BsonFieldCodec<I, O>.catchOut(block: (Throwable) -> O): BsonFieldCodec<I, O> {
147147
val codec = this as Codec<I, O>
148148
return BsonFieldCodec(name, codec catchOut block)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.cufy.kped
16+
package org.cufy.ped
1717

1818
import org.cufy.bson.BsonDateTime
1919
import org.cufy.bson.BsonDecimal128

kped-bson/src/jvmMain/kotlin/BsonCodecs-jvm.kt renamed to ped-bson/src/jvmMain/kotlin/BsonCodecs-jvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.cufy.kped
16+
package org.cufy.ped
1717

1818
import org.cufy.bson.BsonDateTime
1919
import org.cufy.bson.BsonDecimal128
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
1-
package org.cufy.kped
1+
package org.cufy.ped
22

33
import org.cufy.bson.*
44
import kotlin.test.Test
55
import kotlin.test.assertEquals
66

77
class ExampleTest {
8-
@OptIn(ExperimentalBsonApi::class)
9-
@Test
10-
fun `tagged fields`() {
11-
val doc = BsonDocument {
12-
Document1.Name by "default"
13-
Document1.Name lang "en" by "EN"
14-
Document1.Name lang "en-US" by "EN-US"
15-
Document1.Name lang "ar" by "AR"
16-
Document1.Name lang "ar-SA" by "AR-SA"
17-
}
18-
19-
val preference = listOf("en-US", "ar-SA")
20-
val (automatic, automaticLang) = doc[Document1.Name, preference]
21-
val manual = doc[Document1.Name.Nullable lang "ar-SA"]
22-
23-
assertEquals("name#en-US", "name" lang "en-US")
24-
assertEquals(automatic, "EN-US")
25-
assertEquals(automaticLang, "en-US")
26-
assertEquals(manual, "AR-SA")
27-
}
28-
298
@Test
309
fun `common example 1`() {
3110
val id = Id<Document1>()

0 commit comments

Comments
 (0)