Skip to content

Commit

Permalink
Updating readme and build.gradle. All portable classes are serializab…
Browse files Browse the repository at this point in the history
…le as well (JSON, XML,YAML, Binary etc).
  • Loading branch information
SubiyaCryolite committed Aug 26, 2020
1 parent cf76f26 commit fc6b27c
Show file tree
Hide file tree
Showing 38 changed files with 159 additions and 113 deletions.
57 changes: 35 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ Maven
<dependency>
<groupId>io.github.subiyacryolite</groupId>
<artifactId>jds</artifactId>
<version>19.1-SNAPSHOT</version>
<version>20.4-SNAPSHOT</version>
</dependency>
```

Gradle

```groovy
compile 'io.github.subiyacryolite:jds:19.1-SNAPSHOT'
compile 'io.github.subiyacryolite:jds:20.4-SNAPSHOT'
```

# Dependencies
Expand Down Expand Up @@ -86,7 +86,7 @@ Classes that use JDS need to extend Entity.
```kotlin
import io.github.subiyacryolite.jds.Entity;

public class Address extends Entity(){}
public class Address : Entity
```

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

public interface IAddress extends IEntity{}
public class Address extends Entity implements IAddress{}
public interface IAddress : IEntity

public class Address : IAddress
```

Following that the following steps need to be taken.

### 1.1.1 Annotating Classes

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
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

```kotlin
@EntityAnnotation(id = 1, name = "address", description = "An entity representing address information")
class Address : Entity() {}
class Address : Entity()
```

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.
Expand Down Expand Up @@ -332,17 +333,28 @@ import io.github.subiyacryolite.jds.beans.property.NullableShortValue
import io.github.subiyacryolite.jds.tests.constants.Fields
import java.time.LocalDateTime

@EntityAnnotation(id = 1, name = "address", description = "An entity representing address information")
class Address : Entity() {

private val _streetName = map(Fields.StreetName, "", "streetName")
private val _plotNumber = map(Fields.PlotNumber, NullableShortValue(), "plotNumber")
private val _area = map(Fields.ResidentialArea, "", "area")
private val _city = map(Fields.City, "", "city")
private val _provinceOrState = map(Fields.ProvinceOrState, "provinceOrState")
private val _country = map(Fields.Country, "", "country")
private val _primaryAddress = map(Fields.PrimaryAddress, NullableBooleanValue(), "primaryAddress")
private val _timestamp = map(Fields.TimeStamp, LocalDateTime.now(), "timestamp")
data class Address(
private val _streetName: IValue<String> = StringValue(),
private val _plotNumber: IValue<Short?> = NullableShortValue(),
private val _area: IValue<String> = StringValue(),
private val _city: IValue<String> = StringValue(),
private val _provinceOrState: IValue<String> = StringValue(),
private val _country: IValue<String> = StringValue(),
private val _primaryAddress: IValue<Boolean?> = NullableBooleanValue(),
private val _timestamp: IValue<LocalDateTime> = LocalDateTimeValue()
) : Entity(), IAddress {

override fun bind() {
super.bind()
map(Fields.StreetName, _streetName, "streetName")
map(Fields.PlotNumber, _plotNumber, "plotNumber")
map(Fields.ResidentialArea, _area, "area")
map(Fields.City, _city, "city")
map(Fields.ProvinceOrState, _provinceOrState, "provinceOrState")
map(Fields.Country, _country, "country")
map(Fields.PrimaryAddress, _primaryAddress, "primaryAddress")
map(Fields.TimeStamp, _timestamp, "timestamp")
}

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

@EntityAnnotation(id = 2, name = "address_book")
data class AddressBook(
val addresses: MutableCollection<Address> = ArrayList()
val addresses: MutableCollection<IAddress> = ArrayList()
) : Entity() {

init {
override fun bind() {
super.bind()
map(Entities.Addresses, addresses, "addresses")
}
}
Expand Down Expand Up @@ -673,10 +686,10 @@ Once you have defined your class you can initialise them. A dynamic **id** is cr
primaryAddress.primaryAddress = PrimaryAddress.YES
```

### 1.2.4 Saving objects
### 1.2.4 Saving objects (Portable Format)
...

### 1.2.5 Loading objects
### 1.2.5 Loading objects (Portable Format)
...

# Development
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: "io.codearte.nexus-staging"

group = "io.github.subiyacryolite"
version = "20.3-SNAPSHOT"
version = "20.4-SNAPSHOT"
archivesBaseName = project.name
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"
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.interfaces.IOverview
import java.io.Serializable

/**
*
Expand All @@ -26,6 +27,6 @@ data class EntityOverview(
@get:JsonProperty("f")
@set:JsonProperty("f")
var fieldId: Int? = null
) {
): Serializable {
constructor(overview: IOverview, fieldId: Int?) : this(overview.id, overview.editVersion, overview.entityId, fieldId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Entity
import io.github.subiyacryolite.jds.annotations.EntityAnnotation
import io.github.subiyacryolite.jds.context.DbContext
import java.io.Serializable
import java.util.*

/**
Expand All @@ -25,7 +26,7 @@ import java.util.*
data class PortableContainer(
@get:JsonProperty("e")
val portableEntities: MutableCollection<PortableEntity> = ArrayList()
) {
) : Serializable {
/**
* @param dbContext an instance of [DbContext]
* @param entities a collection of [Entity] objects to store in the embedded format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Entity
import io.github.subiyacryolite.jds.context.DbContext
import io.github.subiyacryolite.jds.interfaces.IEntity
import java.io.Serializable

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

@get:JsonProperty("h1")
val mapStringKeyValues: MutableCollection<StoreMapStringKey> = ArrayList()
) {
): Serializable {

@Throws(Exception::class)
fun init(dbContext: DbContext, entity: IEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.util.*

/**
Expand All @@ -30,7 +31,7 @@ data class StoreBlob(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: ByteArray? = null
) {
): Serializable {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable

/**
* Used to store values of type in a portable manner
Expand All @@ -29,4 +30,4 @@ data class StoreBoolean(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Int? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.sql.Timestamp

/**
Expand All @@ -30,4 +31,4 @@ data class StoreDate(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Long? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.sql.Timestamp

/**
Expand All @@ -30,4 +31,4 @@ data class StoreDateTime(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Long? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.sql.Timestamp
import java.util.ArrayList

Expand All @@ -31,4 +32,4 @@ data class StoreDateTimeCollection(
@get:JsonProperty("v")
@set:JsonProperty("v")
var values: Collection<Timestamp> = ArrayList()
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable

/**
* Used to store values of type in a portable manner
Expand All @@ -29,4 +30,4 @@ data class StoreDouble(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Double? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.util.ArrayList

/**
Expand All @@ -30,4 +31,4 @@ data class StoreDoubleCollection(
@get:JsonProperty("v")
@set:JsonProperty("v")
var values: Collection<Double> = ArrayList()
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable

/**
* Used to store values of type in a portable manner
Expand All @@ -29,4 +30,4 @@ data class StoreDuration(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Long? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable

/**
* Used to store values of type in a portable manner
Expand All @@ -29,4 +30,4 @@ data class StoreEnum(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Int? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.util.ArrayList

/**
Expand All @@ -30,4 +31,4 @@ data class StoreEnumCollection(
@get:JsonProperty("v")
@set:JsonProperty("v")
var values: Collection<Int> = ArrayList()
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable

/**
* Used to store values of type in a portable manner
Expand All @@ -29,4 +30,4 @@ data class StoreEnumString(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: String? = null
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable
import java.util.ArrayList

/**
Expand All @@ -30,4 +31,4 @@ data class StoreEnumStringCollection(
@get:JsonProperty("v")
@set:JsonProperty("v")
var values: Collection<String> = ArrayList()
)
): Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.github.subiyacryolite.jds.portable

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.subiyacryolite.jds.Field
import java.io.Serializable

/**
* Used to store values of type in a portable manner
Expand All @@ -29,4 +30,4 @@ data class StoreFloat(
@get:JsonProperty("v")
@set:JsonProperty("v")
var value: Float? = null
)
): Serializable
Loading

0 comments on commit fc6b27c

Please sign in to comment.