3232import com .google .protobuf .Int32Value ;
3333import com .google .protobuf .Int64Value ;
3434import com .google .protobuf .ListValue ;
35- import com .google .protobuf .Message ;
3635import com .google .protobuf .MessageLite ;
3736import com .google .protobuf .MessageLiteOrBuilder ;
3837import com .google .protobuf .NullValue ;
@@ -110,11 +109,7 @@ public MessageLite adaptValueToWellKnownProto(Object value, WellKnownProto wellK
110109 }
111110 }
112111
113- public Any adaptValueToAny (Object value , String typeName ) {
114- if (value instanceof MessageLite ) {
115- return packAnyMessage ((MessageLite ) value , typeName );
116- }
117-
112+ public Any adaptValueToAny (Object value ) {
118113 if (value instanceof dev .cel .common .values .NullValue ) {
119114 return packAnyMessage (
120115 Value .newBuilder ().setNullValue (NullValue .NULL_VALUE ).build (), WellKnownProto .JSON_VALUE );
@@ -234,7 +229,7 @@ private ImmutableMap<String, Object> adaptJsonStructToValue(Struct struct) {
234229 .collect (toImmutableMap (Entry ::getKey , e -> adaptJsonToValue (e .getValue ())));
235230 }
236231
237- private Message adaptValueToDouble (Object value ) {
232+ private MessageLite adaptValueToDouble (Object value ) {
238233 if (value instanceof Double ) {
239234 return DoubleValue .of ((Double ) value );
240235 }
@@ -244,7 +239,7 @@ private Message adaptValueToDouble(Object value) {
244239 throw new IllegalArgumentException ("Unexpected value type: " + value );
245240 }
246241
247- private Message adaptValueToFloat (Object value ) {
242+ private MessageLite adaptValueToFloat (Object value ) {
248243 if (value instanceof Double ) {
249244 return FloatValue .of (((Double ) value ).floatValue ());
250245 }
@@ -254,7 +249,7 @@ private Message adaptValueToFloat(Object value) {
254249 throw new IllegalArgumentException ("Unexpected value type: " + value );
255250 }
256251
257- private Message adaptValueToInt32 (Object value ) {
252+ private MessageLite adaptValueToInt32 (Object value ) {
258253 if (value instanceof Integer ) {
259254 return Int32Value .of ((Integer ) value );
260255 }
@@ -264,7 +259,7 @@ private Message adaptValueToInt32(Object value) {
264259 throw new IllegalArgumentException ("Unexpected value type: " + value );
265260 }
266261
267- private Message adaptValueToInt64 (Object value ) {
262+ private MessageLite adaptValueToInt64 (Object value ) {
268263 if (value instanceof Integer ) {
269264 return Int64Value .of (((Integer ) value ).longValue ());
270265 }
@@ -275,30 +270,22 @@ private Message adaptValueToInt64(Object value) {
275270 throw new IllegalArgumentException ("Unexpected value type: " + value );
276271 }
277272
278- private Message adaptValueToUint32 (Object value ) {
273+ private MessageLite adaptValueToUint32 (Object value ) {
279274 if (value instanceof Integer ) {
280275 return UInt32Value .of ((Integer ) value );
281276 }
282277 // Per the spec, an int isn't a uint, unless unsigned longs are disabled.
283278 if (!celOptions .enableUnsignedLongs () && value instanceof Long ) {
284- try {
285- return UInt32Value .of (unsignedIntCheckedCast ((Long ) value ));
286- } catch (IllegalArgumentException e ) {
287- throw new CelNumericOverflowException (e );
288- }
279+ return UInt32Value .of (unsignedIntCheckedCast ((Long ) value ));
289280 }
290281 if (value instanceof UnsignedLong ) {
291- try {
292- return UInt32Value .of (unsignedIntCheckedCast (((UnsignedLong ) value ).longValue ()));
293- } catch (IllegalArgumentException e ) {
294- throw new CelNumericOverflowException (e );
295- }
282+ return UInt32Value .of (unsignedIntCheckedCast (((UnsignedLong ) value ).longValue ()));
296283 }
297284
298285 throw new IllegalArgumentException ("Unexpected value type: " + value );
299286 }
300287
301- private Message adaptValueToUint64 (Object value ) {
288+ private MessageLite adaptValueToUint64 (Object value ) {
302289 if (value instanceof Integer ) {
303290 return UInt64Value .of (UnsignedInts .toLong ((Integer ) value ));
304291 }
@@ -312,15 +299,15 @@ private Message adaptValueToUint64(Object value) {
312299 throw new IllegalArgumentException ("Unexpected value type: " + value );
313300 }
314301
315- private static int intCheckedCast (long value ) {
302+ static int intCheckedCast (long value ) {
316303 try {
317304 return Ints .checkedCast (value );
318305 } catch (IllegalArgumentException e ) {
319306 throw new CelNumericOverflowException (e );
320307 }
321308 }
322309
323- private static int unsignedIntCheckedCast (long value ) {
310+ static int unsignedIntCheckedCast (long value ) {
324311 try {
325312 return UnsignedInts .checkedCast (value );
326313 } catch (IllegalArgumentException e ) {
0 commit comments