case class - Scala create group of elements -
i want create group of elements in message in below image
updated:
case class element(key:string;value:string) message can represented below
case class msg(field1:element,field2:group) group->represents repeating group - need define group , sub groups
the element defines key=value combination repeated in groups
the following points
are "fields" attributes of fixmessage?
-yes attributes of fix message , each field represented
case class element(key:string;value:string)repeating group
elementrepeating no of timesare keys , values strings?
-consider them string now
field n (field 1, field 2, etc) represent different types?
-yes represent different data types.but can take them of same data type make simple.
output :
key2=value2 ;key3=value3;key4=value=4;key3=value3;key4=value=4;key2=valu e2;key3=value3;key4=value4;key3=value3;key4=value4
explaination
the group key2=value2 repeating 2 times sub group key3=value3;key4=value=4;key3=value3;key4=value=4 gain repeating 2 times in each group (key2=value2) respectively
if understand domain correctly, should work:
case class message(entries: list[entry]) case class entry(name: string, value: value) trait value object value { case class single (v: string) extends value case class group (entries: list[list[entry]]) extends value } message( entry("key 1", value.single("value 1")), entry("key 2", value.group( list( list( entry("key 3", value.single("value 3")), entry("key 4", value.single("value 4")) ), list( entry("key 3", value.single("value 5")), entry("key 4", value.single("value 6")) ) ) )) ) of course helper functions created make nicer dsl it.

Comments
Post a Comment