Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
added things needed for the client
Browse files Browse the repository at this point in the history
  • Loading branch information
fulton committed Jan 8, 2020
1 parent 9e4fa2f commit cc6772b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/main/java/com/andromeda/araserver/iot/GetDeviceClass.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.andromeda.araserver.iot

import com.fasterxml.jackson.dataformat.yaml.YAMLMapper
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import com.google.gson.GsonBuilder
import java.lang.reflect.Modifier.TRANSIENT


class GetDeviceClass {
fun main(url:String):String{
val gson = GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.excludeFieldsWithModifiers(TRANSIENT) // STATIC|TRANSIENT in the default configuration
.create()
val mapper = YAMLMapper().registerKotlinModule()

val mainVal = url.replace("/class/", "")
return gson.toJson(TypeClassMap().main(mainVal))
return mapper.writeValueAsString(TypeClassMap().DeafaultVals(url.replace("/class/", "")))
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/andromeda/araserver/iot/TempModel.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.andromeda.araserver.iot

data class TempModel(val temp:String, val ac:Boolean, val heat:Boolean)
data class TempModel(val temp:Int, val ac:Boolean, val heat:Boolean)
7 changes: 7 additions & 0 deletions src/main/java/com/andromeda/araserver/iot/TypeClassMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ class TypeClassMap {
)
return map[type] as Class<Any>? ?: error("")
}
fun DeafaultVals(main:String): Any? {
val map = mapOf(DeviceConst.LIGHT to LightStatusModel(false, 0, 0), DeviceConst.TEMP to TempModel(30,
ac = false,
heat = false
))
return map[main]
}
}

0 comments on commit cc6772b

Please sign in to comment.