https://github.com/g000sha256/asstring
DEPRECATED
https://github.com/g000sha256/asstring
Last synced: 6 months ago
JSON representation
DEPRECATED
- Host: GitHub
- URL: https://github.com/g000sha256/asstring
- Owner: g000sha256
- License: mit
- Created: 2021-06-22T20:17:01.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-24T18:04:07.000Z (almost 4 years ago)
- Last Synced: 2023-09-04T19:16:02.683Z (over 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: License
Awesome Lists containing this project
README
# AsString
[](https://github.com/g000sha256/AsString/blob/master/License)
[](https://jitpack.io/#g000sha256/AsString)
[](https://travis-ci.com/github/g000sha256/AsString)
[](https://www.codacy.com/gh/g000sha256/AsString)
[](https://www.codacy.com/gh/g000sha256/AsString)This library works with reflection and helps to display an object as a string without using Kotlin `datа` classes. There are 2
extensions for this: `Any.asString` and `Any.asString()`. The extension works only with the current class. So for nested fields,
override the `toString` method with the same extension. Fields from super classes are also displayed.### Setting up the dependency
```groovy
dependencies {
implementation "com.github.g000sha256:AsString:1.0"
}
repositories {
maven { url "https://jitpack.io" }
}
```### Example
```kotlin
class Action(
val actionParam: String = "actionParam",
val data: Data = Data()
) {override fun toString(): String {
return asString()
}}
class Data(
val dataParam: String = "dataParam"
) {override fun toString(): String {
return asString()
}}
``````kotlin
val action = Action()
println("$action")
```displays a
```
Action(actionParam: actionParam, data: Data(dataParam: dataParam))
```An extended example you can see [here](https://github.com/g000sha256/AsString/blob/master/lib/src/test/kotlin/ru/g000sha256/as_string/AsStringTest.kt).