Class CelProtoJsonAdapter


  • @Immutable
    public final class CelProtoJsonAdapter
    extends java.lang.Object
    CelProtoJsonAdapter is 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.ListValue adaptToJsonListValue​(java.lang.Iterable<T> value)
      Adapts an iterable to a JSON list value.
      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.
      static com.google.protobuf.Value adaptValueToJsonValue​(java.lang.Object value)
      Adapts a native Java object to a JSON value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 literal
        java.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.