I'm working on this project in Scala and I'm testing one of my services with a local dynamodb database. I am using the 3rd party library awscala in order to access the table. I'm having a bit of trouble with this part of the code:
override def put(status: Status) = {
require(null != status, "The status object cannot be null.")
table.put(status.id, "State" -> status.state)
}
override def get(id: String): Option[Status] = {
require(StringUtils.isNotBlank(id), "The id of the status cannot be empty/null.")
val state = dynamoDB.get(table, id)
new Status(id, state)
}
Status is a class that I define; it has fields ID: String and state: State, where State is a case class that I defined. When I get something from the table based on the id, and try to create a new Status object, the type of the thing returned is Option[awscala.dynamodbv2.Item] but it requires type enums.State (the case class I defined).
How would I case state to be of type enums.State?
EDIT: Added the definition of state and its case objects.
sealed trait State {}
case object COMPLETED_SUCCESSFULLY extends State {}
case object FINISHED_POLLING extends State {}
case object CURRENTLY_DOWNLOADING extends State {}
case object FINISHED_DOWNLOADING extends State {}
Stateand its members?