Skip to content

Commit 8952577

Browse files
Added typeReference function.
1 parent addeadf commit 8952577

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

CHANGELOG.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This document serves as the change log for the ONIXLabs Corda Core API.
2121
>
2222
> 🔐 **CORDAPP SIGNING**
2323
>
24-
> As of version 1.0.0, this API has been signed with the ONIXLabs production signing key. Historically, clones of this repository would have failed to build, since the signing key is a secret. Version 2.0.0 ships with the ONIXLabs developer key, allowing this repository to be cloned, built and tested locally.
24+
> As of version 1.0.0, packaged releases of this API has been signed with the ONIXLabs production signing key. Historically, clones of this repository would have failed to build, since the ONIXLabs production signing key is a secret. Version 2.0.0 ships with the ONIXLabs developer key, allowing this repository to be cloned, built and tested locally.
2525
2626
---
2727

@@ -31,15 +31,29 @@ This document serves as the change log for the ONIXLabs Corda Core API.
3131

3232
**Package:** io.onixlabs.corda.core
3333

34-
Represents a reference to an underlying type.
34+
Represents a type reference which obtains full generic type information for the underlying generic type.
3535

3636
```kotlin
3737
abstract class TypeReference<T> : Comparable<TypeReference<T>>
3838
```
3939

40-
#### Remarks
40+
> 🔵 **INFORMATION**
41+
>
42+
> This implementation is inspired by the `TypeReference<T>` class in [fasterxml, jackson-core](https://fasterxml.github.io/jackson-core/javadoc/2.8/com/fasterxml/jackson/core/type/TypeReference.html).
4143
42-
This generic abstract class is derived from the `TypeReference<T>` class is jackson fasterxml.
44+
---
45+
46+
### typeReference _Function_
47+
48+
**Module:** onixlabs-corda-core-contract
49+
50+
**Package:** io.onixlabs.corda.core
51+
52+
Creates a type reference of the reified generic type.
53+
54+
```kotlin
55+
inline fun <reified T> typeReference(): TypeReference<T>
56+
```
4357

4458
---
4559

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ buildscript {
4242
}
4343

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

4747
subprojects {
4848
repositories {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
/**
20+
* Creates a type reference of the reified generic type.
21+
*
22+
* @param T The reified generic type for which to obtain type reference information.
23+
* @return Returns a [TypeReference] containing the type information of type [T].
24+
*/
25+
inline fun <reified T> typeReference(): TypeReference<T> {
26+
return object : TypeReference<T>() {}
27+
}

onixlabs-corda-core-contract/src/main/kotlin/io/onixlabs/corda/core/TypeReference.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ import java.lang.reflect.ParameterizedType
2020
import java.lang.reflect.Type
2121

2222
/**
23-
* Represents a reference to an underlying type.
24-
* This generic abstract class is derived from the TypeReference class is jackson fasterxml.
23+
* Represents a type reference which obtains full generic type information for the underlying generic type.
2524
*
26-
* @param T The underlying type.
27-
* @property type The underlying type.
28-
* @property arguments The generic arguments of the underlying type.
25+
* This implementation is inspired by the TypeReference class in fasterxml, jackson-core.
26+
* https://fasterxml.github.io/jackson-core/javadoc/2.8/com/fasterxml/jackson/core/type/TypeReference.html
27+
*
28+
* @param T The underlying type for which to obtain type information.
29+
* @property type The actual underlying type.
30+
* @property arguments The actual generic argument types of the underlying type.
2931
*/
3032
abstract class TypeReference<T> : Comparable<TypeReference<T>> {
3133

0 commit comments

Comments
 (0)