Skip to content

Commit

Permalink
some bug fixing and renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Sep 12, 2022
1 parent 740d41b commit 3b04866
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 63 deletions.
6 changes: 3 additions & 3 deletions Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ And thats it for getting the token.
<dependency>
<groupId>io.github.realyusufismail</groupId>
<artifactId>jconfig</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
</dependency>
```

Expand All @@ -46,11 +46,11 @@ And thats it for getting the token.
```groovy
//kotlin
dependencies {
implementation("io.github.realyusufismail:jconfig:${project.version}")
implementation("io.github.realyusufismail:jconfig:1.0.6")
}
//groovy
dependencies {
implementation "io.github.realyusufismail:jconfig:${project.version}"
implementation "io.github.realyusufismail:jconfig:1.0.6"
}
```
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ And thats it for getting the token.
<dependency>
<groupId>io.github.realyusufismail</groupId>
<artifactId>jconfig</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
</dependency>
```

Expand All @@ -48,12 +48,12 @@ And thats it for getting the token.
```groovy
//kotlin
dependencies {
implementation("io.github.realyusufismail:jconfig:${project.version}")
implementation("io.github.realyusufismail:jconfig:1.0.6")
}
//groovy
dependencies {
implementation "io.github.realyusufismail:jconfig:${project.version}"
implementation "io.github.realyusufismail:jconfig:1.0.6"
}
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extra.apply {
set("name", "JConfig")
set("description", "Json Configurations used to store tokens and other sensitive data")
set("group", "io.github.realyusufismail")
set("version", "1.0.5")
set("version", "1.0.6")
set("dev_id", "yusuf")
set("dev_name", "Yusuf Ismail")
set("dev_email", "yusufgamer222@gmail.com")
Expand All @@ -37,7 +37,7 @@ extra.apply {
}

group = "io.github.realyusufismail"
version = "1.0.5"
version = "1.0.6"

repositories {
mavenCentral()
Expand Down
32 changes: 16 additions & 16 deletions src/main/kotlin/io/github/realyusufismail/jconfig/JConfigObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,50 @@ import java.math.BigInteger
/** Used to get a value as a certain type. */
interface JConfigObject {
/** Get the value as a [String]. */
val string: String
val asString: String

/** Get the value as an [Int]. */
val int: Int
val asInt: Int

/** Get the value as a [BigInteger]. */
val bigInt: BigInteger
val asBigInt: BigInteger

/** Get the value as a [Double]. */
val double: Double
val asDouble: Double

/** Get the value as a [Boolean]. */
val boolean: Boolean
val asBoolean: Boolean

/** Get the value as a [Byte]. */
val byte: Byte
val asByte: Byte

/** Get the value as a [Short]. */
val short: Short
val asShort: Short

/** Get the value as a [Long]. */
val long: Long
val asLong: Long

/** Get the value as a [Float]. */
val float: Float
val asFloat: Float

/** Get the value as a [Char]. */
val char: Char
val asChar: Char

/** Get the value as a [Number]. */
val number: Number
val asNumber: Number

/** Get the value as a [BigDecimal]. */
val decimal: BigDecimal
val asDecimal: BigDecimal

/** Get the value as an [Array]. */
val array: Array<JConfigObject>
val asArray: Array<JConfigObject>

/** Get the value as a [List]. */
val list: List<JConfigObject>
val asList: List<JConfigObject>

/** Get the value as a [Map]. */
val map: Map<String, JConfigObject>
val asMap: Map<String, JConfigObject>

/** Get the value as an [Any]. */
val any: Any
val asAny: Any
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ class JConfigImpl(entries: List<JsonEntry>) : JConfig {
value.isObject ->
JConfigObjectImpl(
value.fields().asSequence().map { it.key to it.value.asText() }.toMap())
else -> throw IllegalArgumentException("Unknown type: ${value.javaClass}")
value.isNull -> throw JConfigException("The value of the key $key is null")
else ->
throw JConfigException("The key $key is not a valid type or is not supported")
}
} else {
throw IllegalArgumentException("Unknown type: ${value.javaClass}")
throw JConfigException("Unknown type: ${value.javaClass}")
}
}

override fun get(key: String, defaultValue: Any): JConfigObject {
return try {
return if (mapEntries.containsKey(key)) {
get(key)
} catch (e: NoSuchElementException) {
} else {
JConfigObjectImpl(defaultValue)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.math.BigInteger

class JConfigObjectImpl(private val value: Any) : JConfigObject {

override val string: String
override val asString: String
get() {
if (value is String) {
return value
Expand All @@ -33,7 +33,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val int: Int
override val asInt: Int
get() {
if (value is Int) {
return value
Expand All @@ -42,7 +42,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val bigInt: BigInteger
override val asBigInt: BigInteger
get() {
if (value is BigInteger) {
return value
Expand All @@ -51,7 +51,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val double: Double
override val asDouble: Double
get() {
if (value is Double) {
return value
Expand All @@ -60,7 +60,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val boolean: Boolean
override val asBoolean: Boolean
get() {
if (value is Boolean) {
return value
Expand All @@ -69,7 +69,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val byte: Byte
override val asByte: Byte
get() {
if (value is Byte) {
return value
Expand All @@ -78,7 +78,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val short: Short
override val asShort: Short
get() {
if (value is Short) {
return value
Expand All @@ -87,7 +87,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val long: Long
override val asLong: Long
get() {
if (value is Long) {
return value
Expand All @@ -96,7 +96,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val float: Float
override val asFloat: Float
get() {
if (value is Float) {
return value
Expand All @@ -105,7 +105,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val char: Char
override val asChar: Char
get() {
if (value is Char) {
return value
Expand All @@ -114,7 +114,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val number: Number
override val asNumber: Number
get() {
if (value is Number) {
return value
Expand All @@ -123,7 +123,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val decimal: BigDecimal
override val asDecimal: BigDecimal
get() {
if (value is BigDecimal) {
return value
Expand All @@ -132,7 +132,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val array: Array<JConfigObject>
override val asArray: Array<JConfigObject>
get() {
if (value is Array<*>) {
return value
Expand All @@ -143,7 +143,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val list: List<JConfigObject>
override val asList: List<JConfigObject>
get() {
if (value is List<*>) {
return value.map {
Expand All @@ -154,7 +154,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val map: Map<String, JConfigObject>
override val asMap: Map<String, JConfigObject>
get() {
if (value is Map<*, *>) {
return value
Expand All @@ -169,7 +169,7 @@ class JConfigObjectImpl(private val value: Any) : JConfigObject {
}
}

override val any: Any
override val asAny: Any
get() {
return value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class JsonEntry
) {

override fun toString(): String {
return "JsonEntry{key='$key', value=$value}"
return "{key: $key, value: $value}"
}

override fun equals(other: Any?): Boolean {
Expand Down
Loading

0 comments on commit 3b04866

Please sign in to comment.