Thrift simulation for list <HashMap <String, Object >>

I have a service method in Java with the following return type:

List<HashMap<String,Object>>

How can I best simulate it in an economical state?

+4
source share
2 answers

Pretty simple:

struct MyObjectData {
    // data of your objects
}

list< map< string, MyObjectData>>

You might want to make it a type:

typedef list< map< string, MyObjectData>>   MyObjectStructure

MyObjectData. Object Object, . Thrift , , , ( class). , union, , :

struct Foo { /* some fields */ }
struct Bar { /* some fields */ }

// a union allows us to store different kinds of structs in one list
union Generic {
  1: Foo foo
  2: Bar bar
}

// technically, a union is more or less a struct with optional fields, 
struct Alternative {
  1: optional Foo foo
  2: optional Bar bar
}

, , :

struct Base { 
    // some fields
}

struct Derived { 
    1: Base base_
    // some more fields
}

. , , .

+6

AFAIK , / , . , . Object. : Apache Thrift

+2

All Articles