Class MoreStructs
Struct messages.
The struct(name, value) helpers can be used to create Struct conveniently,
for example: struct("age", 10).
To build Struct with more than one fields, use StructBuilder; or use
toStruct() to collect from a BiStream.
If you have complex nested data structures such as Multimap<String, Optional<Integer>>,
consider to use Structor, which translates POJO to Struct for common primitive types and
collection types.
- Since:
- 5.8
-
Method Summary
Modifier and TypeMethodDescriptionasMap(com.google.protobuf.Struct struct) Returns aMap<String, Object>view overstruct.static Collector<com.google.protobuf.Struct, ?, com.google.protobuf.Struct> Returns aCollectorthat flattens all fields from the inputStructs and collects them into the finalStruct.static com.google.protobuf.StructReturns a Struct withnameandvalue.static com.google.protobuf.StructReturns a Struct withnameandvalue.static com.google.protobuf.StructReturns a Struct withnameandvalue.static com.google.protobuf.StructReturns a Struct withnameandvalue.static com.google.protobuf.StructReturns a Struct withnameandvalue.static com.google.protobuf.StructReturns a Struct withnameandvalue.static BiCollector<CharSequence, com.google.protobuf.Value, com.google.protobuf.Struct> toStruct()Returns aBiCollectorthat collects the input key-value pairs intoStruct.static <T> Collector<T, ?, com.google.protobuf.Struct> toStruct(Function<? super T, ? extends CharSequence> keyFunction, Function<? super T, com.google.protobuf.Value> valueFunction) Returns aCollectorthat collects input key-value pairs intoStruct.
-
Method Details
-
struct
Returns a Struct withnameandvalue.- Throws:
NullPointerException- ifnameis null
-
struct
Returns a Struct withnameandvalue.- Throws:
NullPointerException- ifnameis null
-
struct
Returns a Struct withnameandvalue.- Throws:
NullPointerException- ifnameorvalueis null
-
struct
Returns a Struct withnameandvalue.- Throws:
NullPointerException- ifnameorvalueis null
-
struct
Returns a Struct withnameandvalue.- Throws:
NullPointerException- ifnameorvalueis null
-
struct
Returns a Struct withnameandvalue.- Throws:
NullPointerException- ifnameorvalueis null
-
toStruct
public static <T> Collector<T, ?, com.google.protobuf.Struct> toStruct(Function<? super T, ? extends CharSequence> keyFunction, Function<? super T, com.google.protobuf.Value> valueFunction) Returns aCollectorthat collects input key-value pairs intoStruct.Duplicate keys (according to
CharSequence.toString()) are not allowed. -
toStruct
public static BiCollector<CharSequence, com.google.protobuf.Value, com.google.protobuf.Struct> toStruct()Returns aBiCollectorthat collects the input key-value pairs intoStruct.Duplicate keys (according to
CharSequence.toString()) are not allowed. -
flatteningToStruct
-
asMap
Returns aMap<String, Object>view overstruct.Valuewrappers are unwrapped usingMoreValues.fromValue(com.google.protobuf.ValueOrBuilder), such thatValues.of(1)is unwrapped to1L,ListValueis unwrapped asList<Object>, andNullValueis unwrapped asnull, etc.Field encounter order is preserved in the result
Map.- Since:
- 5.9
-