com.xantoria.flippy.serialization..ConditionSerializer.scala.swp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flippy Show documentation
Show all versions of flippy Show documentation
A feature switching module for scala applications
b0VIM 7.4 U??W?& ? giftiger_wunsch giftig-fedora-desktop ~giftiger_wunsch/Code/public/flippy/src/main/scala/com/xantoria/flippy/serialization/ConditionSerializer.scala utf-8
3210 #"! U tp j d k ? ad $ ? j ? ? ? ? i G F ? ? ? ) (
?
?
?
?
-
? ? O 3 ? ? ? ? ? ? ? < ! ?
?
?
f
`
\
Z
Y
<
? ? ? ? g I * ? ? ? p l k $ " ! ? ? ? ? d c ? ? ? ? | O N ? k I C B ? ? a ? ? ? m l ? ? ? ? d P = ? ? ? ? ? ? } } } )) JField("condition", Extraction.decompose(cond.inverted)) typeField, JObject(List( val cond = c.asInstanceOf[Condition.Not] def serialize(c: Condition)(implicit formats: Formats): JValue = { ) (data \ "condition").extract[Condition] def deserialize(data: JValue)(implicit formats: Formats): Condition.Not = Condition.Not( def canSerialize(c: Condition) = c.isInstanceOf[Condition.Not] override val typeName: String = "not" object Not extends ConditionSerializer[Condition.Not] { } } JObject(List(typeField, JField("value", serializedValue))) val serializedValue: JValue = Extraction.decompose(new ContextValue(cond.requiredValue)) val cond = c.asInstanceOf[Condition.Equals] override def serialize(c: Condition)(implicit formats: Formats): JValue = { } new Condition.Equals(value) val value: Any = (data \ "value").extract[ContextValue].underlying def deserialize(data: JValue)(implicit formats: Formats): Condition.Equals = { def canSerialize(c: Condition) = c.isInstanceOf[Condition.Equals] override val typeName: String = "equals" object Equals extends ConditionSerializer[Condition.Equals] { object ConditionSerializer { } def deserialize(data: JValue)(implicit formats: Formats): T def serialize(condition: Condition)(implicit formats: Formats): JValue def canSerialize(condition: Condition): Boolean def typeField = JField("condition_type", JString(typeName)) val typeName: String abstract class ConditionSerializer[T <: Condition] { } def apply(): SerializationEngine = new SerializationEngine(DEFAULTS) ) NetworkingSerializer.IPRange StringConditionSerializers.Substring, StringConditionSerializers.Regex, StringConditionSerializers.Range, NamespacedConditionSerializer, ConditionSerializer.False, ConditionSerializer.True, ConditionSerializer.Proportion, ConditionSerializer.Or, ConditionSerializer.Not, ConditionSerializer.Equals, ConditionSerializer.And, final val DEFAULTS: List[ConditionSerializer[_]] = List( object SerializationEngine { } } } serializer.serialize(c) } throw new UnsupportedConditionTypeException(c.getClass.getName) val serializer = conditionTypes.find { _.canSerialize(c) }.getOrElse { case c: Condition => { def serialize(implicit formats: Formats): PartialFunction[Any, JValue] = { } } concrete.deserialize(data).asInstanceOf[Condition] } throw new UnsupportedConditionTypeException(desiredType.getOrElse("none specified")) }.flatten getOrElse { desired: String => conditionTypes.find { _.typeName == desired } val concrete = desiredType.map { val desiredType = (data \ "condition_type").extractOpt[String] case (TypeInfo(Class, _), data) => { def deserialize(implicit formats: Formats): PartialFunction[(TypeInfo, JValue), Condition] = { private val Class = classOf[Condition] ) extends Serializer[Condition] { val conditionTypes: List[ConditionSerializer[_]] class SerializationEngine( class UnsupportedConditionTypeException(condType: String) extends RuntimeException(condType) class MalformedConditionDefinitionException(msg: String) extends RuntimeException(msg) import com.xantoria.flippy.condition.NamespacedCondition import com.xantoria.flippy.condition.Condition import net.liftweb.json.JsonAST._ import net.liftweb.json.{Extraction, Formats, Serializer, ShortTypeHints, TypeInfo} import scala.reflect._ package com.xantoria.flippy.serialization ad ?
< ? ~ z y 4 ? ? ? x I B > < ; } } )) JField("fallback", JBool(cond.fallback)) JField("condition", Extraction.decompose(cond.cond)), JField("attr", JString(cond.attr)), typeField, JObject(List( val cond = c.asInstanceOf[NamespacedCondition] def serialize(c: Condition)(implicit formats: Formats): JValue = { } new NamespacedCondition(attr, condition, fallback) val fallback = (data \ "fallback").extractOpt[Boolean] getOrElse false ad * ? d ? ? ? X W ? ? ? ?
?
?
x
r
q
*
? ? ? ? { u q p 8 ? ? | 0 ?
?
?
n
? ? ? ? t ` M ? ? ? ? ? ? p o % $ ? ? u o n ' ? ? ? ? ? ? ? ? N # " ? ? ? 1 - , ? ? ? ? ? 2 ? ? ? ? u F E ? ? ? k ? ? val condition = (data \ "condition").extract[Condition] } throw new MalformedConditionDefinitionException("[Namespace] Missing attr!") val attr = (data \ "attr").extractOpt[String] getOrElse { def deserialize(data: JValue)(implicit formats: Formats): NamespacedCondition = { def canSerialize(c: Condition) = c.isInstanceOf[NamespacedCondition] override val typeName: String = "namespaced" object NamespacedConditionSerializer extends ConditionSerializer[NamespacedCondition] { } } def serialize(c: Condition)(implicit formats: Formats): JValue = JObject(List(typeField)) def deserialize(data: JValue)(implicit formats: Formats): Condition = Condition.False def canSerialize(c: Condition) = c == Condition.False override val typeName: String = "false" object False extends ConditionSerializer[Condition] { } def serialize(c: Condition)(implicit formats: Formats): JValue = JObject(List(typeField)) def deserialize(data: JValue)(implicit formats: Formats): Condition = Condition.True def canSerialize(c: Condition) = c == Condition.True override val typeName: String = "true" object True extends ConditionSerializer[Condition] { } } )) JField("proportion", JDouble(cond.prop)) typeField, JObject(List( val cond = c.asInstanceOf[Condition.Proportion] def serialize(c: Condition)(implicit formats: Formats): JValue = { } Condition.Proportion(prop) val prop = (data \ "proportion").extract[Double] def deserialize(data: JValue)(implicit formats: Formats): Condition.Proportion = { def canSerialize(c: Condition) = c.isInstanceOf[Condition.Proportion] override val typeName: String = "proportion" object Proportion extends ConditionSerializer[Condition.Proportion] { } } )) JField("conditions", JArray(cond.subs map { Extraction.decompose(_) })) typeField, JObject(List( val cond = c.asInstanceOf[Condition.Or] def serialize(c: Condition)(implicit formats: Formats): JValue = { } Condition.Or(conditions) } throw new MalformedConditionDefinitionException("[Or] No conditions provided") if (conditions.isEmpty) { } throw new MalformedConditionDefinitionException("[Or] Missing 'conditions' attribute") } getOrElse { _.map { _.extract[Condition] } val conditions = (data \ "conditions").extractOpt[List[JValue]] map { def deserialize(data: JValue)(implicit formats: Formats): Condition.Or = { def canSerialize(c: Condition) = c.isInstanceOf[Condition.Or] override val typeName: String = "or" object Or extends ConditionSerializer[Condition.Or] { } } )) JField("conditions", JArray(cond.subs map { Extraction.decompose(_) })) typeField, JObject(List( val cond = c.asInstanceOf[Condition.And] def serialize(c: Condition)(implicit formats: Formats): JValue = { } Condition.And(conditions) } throw new MalformedConditionDefinitionException("[And] No conditions provided") if (conditions.isEmpty) { } throw new MalformedConditionDefinitionException("[And] Missing 'conditions' attribute") } getOrElse { _.map { _.extract[Condition] } val conditions = (data \ "conditions").extractOpt[List[JValue]] map { def deserialize(data: JValue)(implicit formats: Formats): Condition.And = { def canSerialize(c: Condition) = c.isInstanceOf[Condition.And] override val typeName: String = "and" object And extends ConditionSerializer[Condition.And] {
© 2015 - 2024 Weber Informatics LLC | Privacy Policy