Created
July 3, 2018 15:07
-
-
Save madsunrise/a6a8ef7b45de18c9fdaeb37019382837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.atol.tabletpos.engine.mapper | |
import ru.atol.tabletpos.engine.fprint.result.Result | |
import ru.atol.tabletpos.engine.fprint.result.ResultCode | |
import ru.evotor.receipt_storage.db.entity.ResultEntity | |
object ErrorResultMapper { | |
@JvmStatic | |
fun fromErrorResultEntity(resultEntity: ResultEntity?): Result? { | |
if (resultEntity == null) { | |
return null | |
} | |
val result = Result() | |
result.fakeResult = resultEntity.fakeResult ?: false | |
result.errorCode = resultEntity.errorCode ?: 0 | |
result.errorDescription = resultEntity.errorDescription | |
if (resultEntity.resultCodeName != null) { | |
result.result = ResultCode.valueOf(resultEntity.resultCodeName!!) | |
} else { | |
result.result = null | |
} | |
return result | |
} | |
@JvmStatic | |
fun toErrorResultEntity(errorResult: Result): ResultEntity { | |
return ResultEntity.create( | |
errorResult.result.name, | |
errorResult.errorCode, | |
errorResult.errorDescription, | |
errorResult.fakeResult | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment