1919import com .google .common .collect .ImmutableMap ;
2020import com .google .common .primitives .UnsignedLong ;
2121import com .google .errorprone .annotations .Immutable ;
22- import com .google .protobuf .ByteString ;
2322import dev .cel .common .annotations .Internal ;
2423import java .util .Map ;
2524import java .util .Map .Entry ;
3433@ SuppressWarnings ("unchecked" ) // Unchecked cast of generics due to type-erasure (ex: MapValue).
3534@ Internal
3635@ Immutable
37- public class CelValueConverter {
36+ public abstract class CelValueConverter {
3837
3938 /** Adapts a {@link CelValue} to a plain old Java Object. */
4039 public Object fromCelValueToJavaObject (CelValue celValue ) {
@@ -77,10 +76,7 @@ public CelValue fromJavaObjectToCelValue(Object value) {
7776 return (CelValue ) value ;
7877 }
7978
80- if (value instanceof ByteString ) {
81- // TODO: CelConstant should hold this value instead of adapting it here
82- return BytesValue .create (CelByteString .of (((ByteString ) value ).toByteArray ()));
83- } else if (value instanceof Iterable ) {
79+ if (value instanceof Iterable ) {
8480 return toListValue ((Iterable <Object >) value );
8581 } else if (value instanceof Map ) {
8682 return toMapValue ((Map <Object , Object >) value );
@@ -91,9 +87,6 @@ public CelValue fromJavaObjectToCelValue(Object value) {
9187 .orElse (OptionalValue .EMPTY );
9288 } else if (value instanceof Exception ) {
9389 return ErrorValue .create ((Exception ) value );
94- } else if (value instanceof com .google .protobuf .NullValue ) {
95- // TODO: CelConstant should hold this value instead of adapting it here
96- return NullValue .NULL_VALUE ;
9790 }
9891
9992 return fromJavaPrimitiveToCelValue (value );
@@ -152,4 +145,6 @@ private MapValue<CelValue, CelValue> toMapValue(Map<Object, Object> map) {
152145
153146 return ImmutableMapValue .create (mapBuilder .buildOrThrow ());
154147 }
148+
149+ protected CelValueConverter () {}
155150}
0 commit comments