Alexis Hernandez
7 years ago
13 changed files with 97 additions and 28 deletions
@ -0,0 +1,23 @@ |
|||
package com.xsn.explorer.models.fields |
|||
|
|||
import com.xsn.explorer.data.anorm.interpreters.ColumnNameResolver |
|||
import enumeratum._ |
|||
|
|||
sealed abstract class TransactionField(override val entryName: String) extends EnumEntry |
|||
|
|||
object TransactionField extends Enum[TransactionField] { |
|||
|
|||
val values = findValues |
|||
|
|||
case object TransactionId extends TransactionField("txid") |
|||
case object Time extends TransactionField("time") |
|||
case object Sent extends TransactionField("sent") |
|||
case object Received extends TransactionField("received") |
|||
|
|||
implicit val columnNameResolver: ColumnNameResolver[TransactionField] = new ColumnNameResolver[TransactionField] { |
|||
|
|||
override def getUniqueColumnName: String = TransactionId.entryName |
|||
|
|||
override def getColumnName(field: TransactionField): String = field.entryName |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.xsn.explorer.parsers |
|||
|
|||
import com.alexitc.playsonify.models.OrderingCondition |
|||
import com.alexitc.playsonify.parsers.FieldOrderingParser |
|||
import com.xsn.explorer.models.fields.TransactionField |
|||
|
|||
class TransactionOrderingParser extends FieldOrderingParser[TransactionField] { |
|||
|
|||
override protected val defaultField = TransactionField.Time |
|||
|
|||
override protected val defaultOrderingCondition: OrderingCondition = OrderingCondition.DescendingOrder |
|||
|
|||
override protected def parseField(unsafeField: String): Option[TransactionField] = { |
|||
TransactionField.withNameOption(unsafeField) |
|||
} |
|||
} |
Loading…
Reference in new issue