dev.cel.common.values.CelValueConverter Maven / Gradle / Ivy
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dev.cel.common.values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.UnsignedLong;
import dev.cel.common.CelOptions;
import dev.cel.common.annotations.Internal;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
/**
* {@code CelValueConverter} handles bidirectional conversion between native Java objects to {@link
* CelValue}.
*
* CEL Library Internals. Do Not Use.
*/
@SuppressWarnings("unchecked") // Unchecked cast of generics due to type-erasure (ex: MapValue).
@Internal
abstract class CelValueConverter {
protected final CelOptions celOptions;
/** Adapts a {@link CelValue} to a plain old Java Object. */
public Object fromCelValueToJavaObject(CelValue celValue) {
Preconditions.checkNotNull(celValue);
if (celValue instanceof MapValue) {
MapValue mapValue = (MapValue) celValue;
ImmutableMap.Builder
© 2015 - 2025 Weber Informatics LLC | Privacy Policy