Skip to content

Commit

Permalink
added @JvmStatic
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Sep 11, 2022
1 parent 4529672 commit f422092
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ And thats it for getting the token.
<dependency>
<groupId>io.github.realyusufismail</groupId>
<artifactId>jconfig</artifactId>
<version>1.0.0</version>
<version>1.0.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion README.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.0</version>
<version>1.0.3</version>
</dependency>
```

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.0")
set("version", "1.0.3")
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.2"
version = "1.0.3"

repositories {
mavenCentral()
Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/io/github/realyusufismail/jconfig/JConfigUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
fun getString(key: String): String {
if (jConfig[key] is TextNode) {
return (jConfig[key] as TextNode).asText()
Expand All @@ -48,6 +49,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a String.
*/
@JvmStatic
fun getString(key: String, defaultValue: String): String {
return if (jConfig[key] is TextNode) {
(jConfig[key] as TextNode).asText()
Expand All @@ -62,6 +64,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
fun getInt(key: String): Int {
return if (jConfig[key] is IntNode) {
(jConfig[key] as IntNode).asInt()
Expand All @@ -77,6 +80,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as an Int.
*/
@JvmStatic
fun getInt(key: String, defaultValue: Int): Int {
return if (jConfig[key] is IntNode) {
(jConfig[key] as IntNode).intValue()
Expand All @@ -91,6 +95,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
fun getBoolean(key: String): Boolean {
return if (jConfig[key] is BooleanNode) {
(jConfig[key] as BooleanNode).booleanValue()
Expand All @@ -107,6 +112,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a Boolean.
*/
@JvmStatic
fun getBoolean(key: String, defaultValue: Boolean): Boolean {
return if (jConfig[key, defaultValue] is BooleanNode) {
(jConfig[key, defaultValue] as BooleanNode).booleanValue()
Expand All @@ -121,6 +127,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
fun getDouble(key: String): Double {
return if (jConfig[key] is DoubleNode) {
(jConfig[key] as DoubleNode).doubleValue()
Expand All @@ -137,6 +144,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a Double.
*/
@JvmStatic
fun getDouble(key: String, defaultValue: Double): Double {
return if (jConfig[key] is DoubleNode) {
(jConfig[key] as DoubleNode).doubleValue()
Expand All @@ -151,6 +159,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
fun getLong(key: String): Long {
return if (jConfig[key] is LongNode) {
(jConfig[key] as LongNode).longValue()
Expand All @@ -166,6 +175,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a Long.
*/
@JvmStatic
fun getLong(key: String, defaultValue: Long): Long {
return if (jConfig[key] is LongNode) {
(jConfig[key] as LongNode).longValue()
Expand All @@ -180,6 +190,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
fun getFloat(key: String): Float {
return if (jConfig[key] is FloatNode) {
(jConfig[key] as FloatNode).floatValue()
Expand All @@ -195,6 +206,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a Float.
*/
@JvmStatic
fun getFloat(key: String, defaultValue: Float): Float {
return if (jConfig[key, defaultValue] is FloatNode) {
(jConfig[key, defaultValue] as FloatNode).floatValue()
Expand All @@ -209,6 +221,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value as a List.
*/
@JvmStatic
fun getListNode(key: String): List<*> {
return if (jConfig[key] is ArrayNode) {
(jConfig[key] as ArrayNode).toList()
Expand All @@ -224,6 +237,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a List.
*/
@JvmStatic
fun getListNode(key: String, defaultValue: List<*>): List<*> {
return if (jConfig[key, defaultValue] is ArrayNode) {
(jConfig[key, defaultValue] as ArrayNode).toList()
Expand All @@ -238,6 +252,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value as a Map.
*/
@JvmStatic
fun getMapNode(key: String): Map<*, *> {
return if (jConfig[key] is ObjectNode) {
(jConfig[key] as ObjectNode).fields().asSequence().associate { it.key to it.value }
Expand All @@ -253,6 +268,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as a Map.
*/
@JvmStatic
fun getMapNode(key: String, defaultValue: Map<*, *>): Map<*, *> {
return if (jConfig[key, defaultValue] is ObjectNode) {
(jConfig[key, defaultValue] as ObjectNode).fields().asSequence().associate {
Expand All @@ -269,6 +285,7 @@ class JConfigUtils {
* @param key The key to get the value of.
* @return The value of the specified key.
*/
@JvmStatic
operator fun get(key: String): Any {
return jConfig[key]
}
Expand All @@ -280,6 +297,7 @@ class JConfigUtils {
* @param defaultValue The default value to return if the value is not found.
* @return The value as an Any.
*/
@JvmStatic
operator fun get(key: String, defaultValue: Any): Any {
return jConfig[key, defaultValue]
}
Expand Down

0 comments on commit f422092

Please sign in to comment.