Skip to content

Commit fc6b27c

Browse files
Updating readme and build.gradle. All portable classes are serializable as well (JSON, XML,YAML, Binary etc).
1 parent cf76f26 commit fc6b27c

38 files changed

+159
-113
lines changed

README.md

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ Maven
5050
<dependency>
5151
<groupId>io.github.subiyacryolite</groupId>
5252
<artifactId>jds</artifactId>
53-
<version>19.1-SNAPSHOT</version>
53+
<version>20.4-SNAPSHOT</version>
5454
</dependency>
5555
```
5656

5757
Gradle
5858

5959
```groovy
60-
compile 'io.github.subiyacryolite:jds:19.1-SNAPSHOT'
60+
compile 'io.github.subiyacryolite:jds:20.4-SNAPSHOT'
6161
```
6262

6363
# Dependencies
@@ -86,7 +86,7 @@ Classes that use JDS need to extend Entity.
8686
```kotlin
8787
import io.github.subiyacryolite.jds.Entity;
8888

89-
public class Address extends Entity(){}
89+
public class Address : Entity
9090
```
9191

9292
However, if you plan on using interfaces they must extend IEntity. Concrete classes can then extend Entity
@@ -95,19 +95,20 @@ However, if you plan on using interfaces they must extend IEntity. Concrete clas
9595
import io.github.subiyacryolite.jds.Entity;
9696
import io.github.subiyacryolite.jds.IEntity;
9797

98-
public interface IAddress extends IEntity{}
99-
public class Address extends Entity implements IAddress{}
98+
public interface IAddress : IEntity
99+
100+
public class Address : IAddress
100101
```
101102

102103
Following that the following steps need to be taken.
103104

104105
### 1.1.1 Annotating Classes
105106

106-
Every class that extends Entity must have its own unique Entity Id as well as an Entity Name. This is done by annotating the class in the following manner
107+
Every class that extends Entity must have its own unique Entity Id as well as an Entity Name. This is done by annotating the class, or its parent interface, in the following manner
107108

108109
```kotlin
109110
@EntityAnnotation(id = 1, name = "address", description = "An entity representing address information")
110-
class Address : Entity() {}
111+
class Address : Entity()
111112
```
112113

113114
Entity IDs MUST be unique in your application, any value of type long is valid. Entity Names do not enforce unique constraints but its best to use a unique name regardless. These values can be referenced to mine data.
@@ -332,17 +333,28 @@ import io.github.subiyacryolite.jds.beans.property.NullableShortValue
332333
import io.github.subiyacryolite.jds.tests.constants.Fields
333334
import java.time.LocalDateTime
334335

335-
@EntityAnnotation(id = 1, name = "address", description = "An entity representing address information")
336-
class Address : Entity() {
337-
338-
private val _streetName = map(Fields.StreetName, "", "streetName")
339-
private val _plotNumber = map(Fields.PlotNumber, NullableShortValue(), "plotNumber")
340-
private val _area = map(Fields.ResidentialArea, "", "area")
341-
private val _city = map(Fields.City, "", "city")
342-
private val _provinceOrState = map(Fields.ProvinceOrState, "provinceOrState")
343-
private val _country = map(Fields.Country, "", "country")
344-
private val _primaryAddress = map(Fields.PrimaryAddress, NullableBooleanValue(), "primaryAddress")
345-
private val _timestamp = map(Fields.TimeStamp, LocalDateTime.now(), "timestamp")
336+
data class Address(
337+
private val _streetName: IValue<String> = StringValue(),
338+
private val _plotNumber: IValue<Short?> = NullableShortValue(),
339+
private val _area: IValue<String> = StringValue(),
340+
private val _city: IValue<String> = StringValue(),
341+
private val _provinceOrState: IValue<String> = StringValue(),
342+
private val _country: IValue<String> = StringValue(),
343+
private val _primaryAddress: IValue<Boolean?> = NullableBooleanValue(),
344+
private val _timestamp: IValue<LocalDateTime> = LocalDateTimeValue()
345+
) : Entity(), IAddress {
346+
347+
override fun bind() {
348+
super.bind()
349+
map(Fields.StreetName, _streetName, "streetName")
350+
map(Fields.PlotNumber, _plotNumber, "plotNumber")
351+
map(Fields.ResidentialArea, _area, "area")
352+
map(Fields.City, _city, "city")
353+
map(Fields.ProvinceOrState, _provinceOrState, "provinceOrState")
354+
map(Fields.Country, _country, "country")
355+
map(Fields.PrimaryAddress, _primaryAddress, "primaryAddress")
356+
map(Fields.TimeStamp, _timestamp, "timestamp")
357+
}
346358

347359
var primaryAddress: Boolean?
348360
get() = _primaryAddress.get()
@@ -409,10 +421,11 @@ import io.github.subiyacryolite.jds.tests.constants.Entities
409421

410422
@EntityAnnotation(id = 2, name = "address_book")
411423
data class AddressBook(
412-
val addresses: MutableCollection<Address> = ArrayList()
424+
val addresses: MutableCollection<IAddress> = ArrayList()
413425
) : Entity() {
414426

415-
init {
427+
override fun bind() {
428+
super.bind()
416429
map(Entities.Addresses, addresses, "addresses")
417430
}
418431
}
@@ -673,10 +686,10 @@ Once you have defined your class you can initialise them. A dynamic **id** is cr
673686
primaryAddress.primaryAddress = PrimaryAddress.YES
674687
```
675688

676-
### 1.2.4 Saving objects
689+
### 1.2.4 Saving objects (Portable Format)
677690
...
678691

679-
### 1.2.5 Loading objects
692+
### 1.2.5 Loading objects (Portable Format)
680693
...
681694

682695
# Development

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ apply plugin: "org.jetbrains.dokka"
2525
apply plugin: "io.codearte.nexus-staging"
2626

2727
group = "io.github.subiyacryolite"
28-
version = "20.3-SNAPSHOT"
28+
version = "20.4-SNAPSHOT"
2929
archivesBaseName = project.name
3030
description = "A dynamic, cross platform and high performance data-mapper. JDS is designed to assist in rapid development and the creation of robust, strongly typed, field dictionaries"
3131
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"

src/main/kotlin/io/github/subiyacryolite/jds/portable/EntityOverview.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.github.subiyacryolite.jds.portable
22

33
import com.fasterxml.jackson.annotation.JsonProperty
44
import io.github.subiyacryolite.jds.interfaces.IOverview
5+
import java.io.Serializable
56

67
/**
78
*
@@ -26,6 +27,6 @@ data class EntityOverview(
2627
@get:JsonProperty("f")
2728
@set:JsonProperty("f")
2829
var fieldId: Int? = null
29-
) {
30+
): Serializable {
3031
constructor(overview: IOverview, fieldId: Int?) : this(overview.id, overview.editVersion, overview.entityId, fieldId)
3132
}

src/main/kotlin/io/github/subiyacryolite/jds/portable/PortableContainer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Entity
1818
import io.github.subiyacryolite.jds.annotations.EntityAnnotation
1919
import io.github.subiyacryolite.jds.context.DbContext
20+
import java.io.Serializable
2021
import java.util.*
2122

2223
/**
@@ -25,7 +26,7 @@ import java.util.*
2526
data class PortableContainer(
2627
@get:JsonProperty("e")
2728
val portableEntities: MutableCollection<PortableEntity> = ArrayList()
28-
) {
29+
) : Serializable {
2930
/**
3031
* @param dbContext an instance of [DbContext]
3132
* @param entities a collection of [Entity] objects to store in the embedded format

src/main/kotlin/io/github/subiyacryolite/jds/portable/PortableEntity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Entity
1818
import io.github.subiyacryolite.jds.context.DbContext
1919
import io.github.subiyacryolite.jds.interfaces.IEntity
20+
import java.io.Serializable
2021

2122
/**
2223
* Class used to represent [JdsEntity][Entity] objects in a portable manner
@@ -125,7 +126,7 @@ data class PortableEntity(
125126

126127
@get:JsonProperty("h1")
127128
val mapStringKeyValues: MutableCollection<StoreMapStringKey> = ArrayList()
128-
) {
129+
): Serializable {
129130

130131
@Throws(Exception::class)
131132
fun init(dbContext: DbContext, entity: IEntity) {

src/main/kotlin/io/github/subiyacryolite/jds/portable/StoreBlob.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable
1515

1616
import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Field
18+
import java.io.Serializable
1819
import java.util.*
1920

2021
/**
@@ -30,7 +31,7 @@ data class StoreBlob(
3031
@get:JsonProperty("v")
3132
@set:JsonProperty("v")
3233
var value: ByteArray? = null
33-
) {
34+
): Serializable {
3435
override fun equals(other: Any?): Boolean {
3536
if (this === other) return true
3637
if (javaClass != other?.javaClass) return false

src/main/kotlin/io/github/subiyacryolite/jds/portable/StoreBoolean.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable
1515

1616
import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Field
18+
import java.io.Serializable
1819

1920
/**
2021
* Used to store values of type in a portable manner
@@ -29,4 +30,4 @@ data class StoreBoolean(
2930
@get:JsonProperty("v")
3031
@set:JsonProperty("v")
3132
var value: Int? = null
32-
)
33+
): Serializable

src/main/kotlin/io/github/subiyacryolite/jds/portable/StoreDate.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable
1515

1616
import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Field
18+
import java.io.Serializable
1819
import java.sql.Timestamp
1920

2021
/**
@@ -30,4 +31,4 @@ data class StoreDate(
3031
@get:JsonProperty("v")
3132
@set:JsonProperty("v")
3233
var value: Long? = null
33-
)
34+
): Serializable

src/main/kotlin/io/github/subiyacryolite/jds/portable/StoreDateTime.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable
1515

1616
import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Field
18+
import java.io.Serializable
1819
import java.sql.Timestamp
1920

2021
/**
@@ -30,4 +31,4 @@ data class StoreDateTime(
3031
@get:JsonProperty("v")
3132
@set:JsonProperty("v")
3233
var value: Long? = null
33-
)
34+
): Serializable

src/main/kotlin/io/github/subiyacryolite/jds/portable/StoreDateTimeCollection.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable
1515

1616
import com.fasterxml.jackson.annotation.JsonProperty
1717
import io.github.subiyacryolite.jds.Field
18+
import java.io.Serializable
1819
import java.sql.Timestamp
1920
import java.util.ArrayList
2021

@@ -31,4 +32,4 @@ data class StoreDateTimeCollection(
3132
@get:JsonProperty("v")
3233
@set:JsonProperty("v")
3334
var values: Collection<Timestamp> = ArrayList()
34-
)
35+
): Serializable

0 commit comments

Comments
 (0)