case class - Scala create group of elements -


i want create group of elements in message in below image

enter image description here

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

  1. are "fields" attributes of fixmessage?

    -yes attributes of fix message , each field represented case class element(key:string;value:string)

  2. repeating group element repeating no of times

  3. are keys , values strings?

    -consider them string now

  4. 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;key‌​4=value4;key3=value‌​3;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

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -