simter-kotlin

Simter kotlin extension

License

License

MIT
Categories

Categories

Kotlin Languages
GroupId

GroupId

tech.simter
ArtifactId

ArtifactId

simter-kotlin
Last Version

Last Version

1.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

simter-kotlin
Simter kotlin extension
Project URL

Project URL

https://github.com/simter/simter-kotlin
Project Organization

Project Organization

simter
Source Code Management

Source Code Management

https://github.com/simter/simter-kotlin.git

Download simter-kotlin

How to add to project

<!-- https://jarcasting.com/artifacts/tech.simter/simter-kotlin/ -->
<dependency>
    <groupId>tech.simter</groupId>
    <artifactId>simter-kotlin</artifactId>
    <version>1.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/tech.simter/simter-kotlin/
implementation 'tech.simter:simter-kotlin:1.3.0'
// https://jarcasting.com/artifacts/tech.simter/simter-kotlin/
implementation ("tech.simter:simter-kotlin:1.3.0")
'tech.simter:simter-kotlin:jar:1.3.0'
<dependency org="tech.simter" name="simter-kotlin" rev="1.3.0">
  <artifact name="simter-kotlin" type="jar" />
</dependency>
@Grapes(
@Grab(group='tech.simter', module='simter-kotlin', version='1.3.0')
)
libraryDependencies += "tech.simter" % "simter-kotlin" % "1.3.0"
[tech.simter/simter-kotlin "1.3.0"]

Dependencies

compile (6)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib Optional jar
tech.simter : simter-util jar 1.1.0
org.jetbrains.kotlin : kotlin-reflect Optional jar
org.springframework.data : spring-data-commons Optional jar
javax.persistence : javax.persistence-api Optional jar 2.2
com.fasterxml.jackson.core : jackson-annotations Optional jar

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar
org.slf4j : jcl-over-slf4j jar
ch.qos.logback : logback-classic jar
org.springframework.boot : spring-boot-starter-test jar 2.1.6.RELEASE
io.projectreactor : reactor-test jar

Project Modules

There are no modules declared in this project.

simter-kotlin [中文]

Simter kotlin extension.

1. DynamicBean class

A super class for define a dynamic bean by inheritance.

  1. Use pattern 'var {propertyName}: {valueType}? by holder' to define a dynamic property in your dynamic bean class.
  2. To define a dynamic property, the subclass property must be mutable (var), nullable (T?) and no default value.
  3. The data property holds all settled dynamic property name and value. By default, it's a empty Map.
class MyBean : DynamicBean() {
  var property1: String? by holder
  var property2: Int? by holder
}

@Test
fun test() {
  val bean = MyBean()
  assertNotNull(bean.data)
  assertEquals(0, bean.data.size)

  // default value is null if not settled
  assertNull(bean.data["property1"])

  // set null value
  bean.property1 = null
  assertEquals(1, bean.data.size)
  assertNull(bean.data["property1"])

  // set not null value
  bean.property1 = "value1"
  assertEquals(1, bean.data.size)
  assertEquals("value1", bean.data["property1"])

  // set another property
  bean.property2 = 123
  assertEquals(2, bean.data.size)
  assertEquals("value1", bean.data["property1"])
  assertEquals(123, bean.data["property2"])
}
tech.simter

Versions

Version
1.3.0
1.0.0