Skip to content

Commit a4beb66

Browse files
Majority of version 2.0.0 features implemented.
1 parent ee7a061 commit a4beb66

File tree

120 files changed

+5573
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+5573
-275
lines changed

.idea/runConfigurations/Run_Contract_Tests.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Run_Workflow_Tests.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,50 @@ Rather than commands simply being marker objects to determine which verification
9292

9393
---
9494

95+
### cast *Extension Function*
96+
97+
**Module:** onixlabs-corda-core-contract
98+
99+
**Package:** io.onixlabs.corda.core.contract
100+
101+
#### Description
102+
103+
Casts a `StateAndRef` of an unknown `ContractState` to a `StateAndRef` of type `T`.
104+
105+
```kotlin
106+
fun <T> StateAndRef<*>.cast(contractStateClass: Class<T>): StateAndRef<T> where T : ContractState
107+
108+
inline fun <reified T> StateAndRef<*>.cast(): StateAndRef<T> where T : ContractState
109+
```
110+
111+
> 🔵 **INFORMATION**
112+
>
113+
> This API exists in version 1.0.0 but only using reified generics.
114+
115+
---
116+
117+
### cast *Extension Function*
118+
119+
**Module:** onixlabs-corda-core-contract
120+
121+
**Package:** io.onixlabs.corda.core.contract
122+
123+
#### Description
124+
125+
Casts an iterable of `StateAndRef` of an unknown `ContractState` to a list of `StateAndRef` of type `T`.
126+
127+
```kotlin
128+
fun <T> Iterable<StateAndRef<*>>.cast(contractStateClass: Class<T>): List<StateAndRef<T>> where T : ContractState
129+
130+
inline fun <reified T> Iterable<StateAndRef<*>>.cast(): List<StateAndRef<T>> where T : ContractState
131+
```
132+
133+
> 🔵 **INFORMATION**
134+
>
135+
> This API exists in version 1.1.0 but only using reified generics.
136+
137+
---
138+
95139
## Version 1.1.0
96140

97141
> 🔵 **INFORMATION**

HEADER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2020 Matthew Layton
2+
* Copyright 2020-2021 Matthew Layton
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ buildscript {
2323
cordapp_signing_enabled = true
2424
cordapp_signing_alias = 'cordapp-signer'
2525
cordapp_signing_storetype = 'PKCS12'
26-
cordapp_signing_keystore = getProperty('jar.sign.keystore')
27-
cordapp_signing_password = getProperty('jar.sign.password')
26+
cordapp_signing_keystore = findProperty('onixlabs.production.jarsign.keystore') ?: getProperty('onixlabs.development.jarsign.keystore')
27+
cordapp_signing_password = findProperty('onixlabs.production.jarsign.password') ?: getProperty('onixlabs.development.jarsign.password')
2828
}
2929

3030
repositories {
@@ -42,7 +42,7 @@ buildscript {
4242
}
4343

4444
group 'io.onixlabs'
45-
version '1.2.0'
45+
version '2.0.0-rc1'
4646

4747
subprojects {
4848
repositories {

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name=onixlabs-corda-core
22
group=io.onixlabs
33
version=0.1
4+
45
kotlin.incremental=false
56
kotlin.code.style=official
7+
8+
onixlabs.development.jarsign.keystore=../lib/onixlabs.development.pkcs12
9+
onixlabs.development.jarsign.password=5891f47942424d2acbe108691fdb5ba258712fca7e4762be4327241ebf3dbfa3

lib/onixlabs.development.jks

2.18 KB
Binary file not shown.

lib/onixlabs.development.pkcs12

2.54 KB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright 2020-2021 Matthew Layton
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.onixlabs.corda.core
18+
19+
import java.lang.reflect.ParameterizedType
20+
import java.lang.reflect.Type
21+
22+
/**
23+
* Gets the argument types from a generic superclass.
24+
*
25+
* @return Returns a list of generic argument types.
26+
* @throws IllegalArgumentException if the superclass is not a [ParameterizedType].
27+
*/
28+
fun Class<*>.getArgumentTypes(): List<Type> {
29+
val superClass = genericSuperclass
30+
return (superClass as? ParameterizedType)?.actualTypeArguments?.toList()
31+
?: throw IllegalArgumentException("Cannot obtain generic argument types from a non-parameterized type.")
32+
}
33+
34+
/**
35+
* Gets a argument type from a generic superclass.
36+
*
37+
* @param index The index of the argument to get.
38+
* @return Returns a list of generic argument types.
39+
* @throws IllegalArgumentException if the superclass is not a [ParameterizedType].
40+
*/
41+
fun Class<*>.getArgumentType(index: Int): Type {
42+
return getArgumentTypes()[index]
43+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright 2020-2021 Matthew Layton
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.onixlabs.corda.core
18+
19+
import java.lang.reflect.ParameterizedType
20+
import java.lang.reflect.Type
21+
import java.lang.reflect.WildcardType
22+
23+
/**
24+
* Converts a type to a class.
25+
*/
26+
fun Type.toClass(): Class<*> = when (this) {
27+
is ParameterizedType -> rawType.toClass()
28+
is WildcardType -> this.upperBounds[0].toClass()
29+
is Class<*> -> this
30+
else -> Class.forName(typeName)
31+
}
32+
33+
/**
34+
* Converts a type to a class.
35+
*/
36+
@Suppress("UNCHECKED_CAST")
37+
fun <T> Type.toTypedClass(): Class<T> {
38+
return toClass() as Class<T>
39+
}

0 commit comments

Comments
 (0)