Class DescriptorMessageProvider
- java.lang.Object
-
- dev.cel.runtime.DescriptorMessageProvider
-
- All Implemented Interfaces:
MessageProvider,RuntimeTypeProvider,TypeResolver
@Immutable @Internal public final class DescriptorMessageProvider extends java.lang.Object implements RuntimeTypeProvider
An implementation ofRuntimeTypeProviderwhich relies on proto descriptors.This can handle all messages providable by the given
MessageFactory. In addition, one can provide message descriptors for messages external to the program which are provided via aDynamicMessageFactory.CEL Library Internals. Do Not Use.
-
-
Constructor Summary
Constructors Constructor Description DescriptorMessageProvider(ProtoMessageFactory protoMessageFactory, CelOptions celOptions)Create a new message provider with a given message factory and custom descriptor set to use when adapting from proto to CEL and vice versa.DescriptorMessageProvider(MessageFactory messageFactory)Deprecated.Migrate to the CEL-Java fluent APIs.DescriptorMessageProvider(MessageFactory messageFactory, com.google.common.collect.ImmutableSet<ExprFeatures> features)Deprecated.Migrate to the CEL-Java fluent APIs.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Objectadapt(java.lang.Object message)Adapt object to its message value.@Nullable ValueadaptType(@Nullable Type type)Deprecated.ValueadaptType(CelType type)Adapt the check-timetypeinstance to a runtimeValue.@Nullable java.lang.ObjectcreateMessage(java.lang.String messageName, java.util.Map<java.lang.String,java.lang.Object> values)Create a message based on the fully qualified message name and field-value mapping.java.lang.ObjecthasField(java.lang.Object message, java.lang.String fieldName)Check whether a field is set on message.@Nullable ValueresolveObjectType(java.lang.Object obj, @Nullable Value checkedTypeValue)Resolve the CEL type of theobj, using thecheckedTypeValueas hint for type disambiguation.@Nullable java.lang.ObjectselectField(java.lang.Object message, java.lang.String fieldName)Select field from message.
-
-
-
Constructor Detail
-
DescriptorMessageProvider
@Deprecated public DescriptorMessageProvider(MessageFactory messageFactory)
Deprecated.Migrate to the CEL-Java fluent APIs. SeeCelRuntimeFactory.Creates a new message provider with the given message factory.
-
DescriptorMessageProvider
@Deprecated public DescriptorMessageProvider(MessageFactory messageFactory, com.google.common.collect.ImmutableSet<ExprFeatures> features)
Deprecated.Migrate to the CEL-Java fluent APIs. SeeCelRuntimeFactory.Creates a new message provider with the given message factory and a set of customizedfeatures.
-
DescriptorMessageProvider
public DescriptorMessageProvider(ProtoMessageFactory protoMessageFactory, CelOptions celOptions)
Create a new message provider with a given message factory and custom descriptor set to use when adapting from proto to CEL and vice versa.
-
-
Method Detail
-
resolveObjectType
public @Nullable Value resolveObjectType(java.lang.Object obj, @Nullable Value checkedTypeValue)
Description copied from interface:TypeResolverResolve the CEL type of theobj, using thecheckedTypeValueas hint for type disambiguation.The
checkedTypeValueindicates the statically determined type of the object at check-time. Often, the check-time and runtime phases agree, but there are cases where the runtime type is ambiguous, as is the case when aLongvalue is supplied as this could either be an int, uint, or enum type.Type resolution is biased toward the runtime value type, given the dynamically typed nature of CEL.
- Specified by:
resolveObjectTypein interfaceTypeResolver
-
adaptType
public Value adaptType(CelType type)
Adapt the check-timetypeinstance to a runtimeValue.When the checked
typedoes not have a runtime equivalent, e.g.Type#DYN, the return value will benull.- Specified by:
adaptTypein interfaceTypeResolver
-
adaptType
@Deprecated public @Nullable Value adaptType(@Nullable Type type)
Deprecated.Description copied from interface:TypeResolverAdapt the check-timetypeinstance to a runtimeValue.When the checked
typedoes not have a runtime equivalent, e.g.Type#DYN, the return value will benull.- Specified by:
adaptTypein interfaceTypeResolver
-
createMessage
public @Nullable java.lang.Object createMessage(java.lang.String messageName, java.util.Map<java.lang.String,java.lang.Object> values)Description copied from interface:MessageProviderCreate a message based on the fully qualified message name and field-value mapping.- Specified by:
createMessagein interfaceMessageProvider
-
selectField
public @Nullable java.lang.Object selectField(java.lang.Object message, java.lang.String fieldName)Description copied from interface:MessageProviderSelect field from message.- Specified by:
selectFieldin interfaceMessageProvider
-
adapt
public java.lang.Object adapt(java.lang.Object message)
Adapt object to its message value.- Specified by:
adaptin interfaceMessageProvider
-
hasField
public java.lang.Object hasField(java.lang.Object message, java.lang.String fieldName)Description copied from interface:MessageProviderCheck whether a field is set on message.- Specified by:
hasFieldin interfaceMessageProvider
-
-