Package dev.cel.common
Class CelProtoJsonAdapter
- java.lang.Object
-
- dev.cel.common.CelProtoJsonAdapter
-
@Immutable public final class CelProtoJsonAdapter extends java.lang.ObjectCelProtoJsonAdapteris a utility to handle conversion from Java native objects representing CEL values to Protobuf's structured value which maps to JSON object schema.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> com.google.protobuf.ListValueadaptToJsonListValue(java.lang.Iterable<T> value)Adapts an iterable to a JSON list value.static <K extends java.lang.String,V>
com.google.protobuf.StructadaptToJsonStructValue(java.util.Map<K,V> map)Adapts a map to a JSON Struct.static com.google.protobuf.ValueadaptValueToJsonValue(java.lang.Object value)Adapts a native Java object to a JSON value.
-
-
-
Method Detail
-
adaptToJsonStructValue
public static <K extends java.lang.String,V> com.google.protobuf.Struct adaptToJsonStructValue(java.util.Map<K,V> map)
Adapts a map to a JSON Struct.- Throws:
java.lang.ClassCastException- If the key is not a string literaljava.lang.IllegalArgumentException- If any of the map's value is not convertible to a canonical JSON representation defined by protobuf.
-
adaptValueToJsonValue
public static com.google.protobuf.Value adaptValueToJsonValue(java.lang.Object value)
Adapts a native Java object to a JSON value.- Throws:
java.lang.IllegalArgumentException- If the value is not convertible to a canonical JSON * representation defined by protobuf.
-
adaptToJsonListValue
public static <T> com.google.protobuf.ListValue adaptToJsonListValue(java.lang.Iterable<T> value)
Adapts an iterable to a JSON list value.- Throws:
java.lang.IllegalArgumentException- If any of the map's value is not convertible to a canonical JSON representation defined by protobuf.
-
-