Class DescriptorMessageProvider

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object adapt​(java.lang.Object message)
      Adapt object to its message value.
      @Nullable Value adaptType​(@Nullable Type type)
      Deprecated.
      Value adaptType​(CelType type)
      Adapt the check-time type instance to a runtime Value.
      @Nullable java.lang.Object createMessage​(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.Object hasField​(java.lang.Object message, java.lang.String fieldName)
      Check whether a field is set on message.
      @Nullable Value resolveObjectType​(java.lang.Object obj, @Nullable Value checkedTypeValue)
      Resolve the CEL type of the obj, using the checkedTypeValue as hint for type disambiguation.
      @Nullable java.lang.Object selectField​(java.lang.Object message, java.lang.String fieldName)
      Select field from message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DescriptorMessageProvider

        @Deprecated
        public DescriptorMessageProvider​(MessageFactory messageFactory)
        Deprecated.
        Migrate to the CEL-Java fluent APIs. See CelRuntimeFactory.
        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. See CelRuntimeFactory.
        Creates a new message provider with the given message factory and a set of customized features.
      • 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: TypeResolver
        Resolve the CEL type of the obj, using the checkedTypeValue as hint for type disambiguation.

        The checkedTypeValue indicates 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 a Long value 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:
        resolveObjectType in interface TypeResolver
      • adaptType

        public Value adaptType​(CelType type)
        Adapt the check-time type instance to a runtime Value.

        When the checked type does not have a runtime equivalent, e.g. Type#DYN, the return value will be null.

        Specified by:
        adaptType in interface TypeResolver
      • adaptType

        @Deprecated
        public @Nullable Value adaptType​(@Nullable Type type)
        Deprecated.
        Description copied from interface: TypeResolver
        Adapt the check-time type instance to a runtime Value.

        When the checked type does not have a runtime equivalent, e.g. Type#DYN, the return value will be null.

        Specified by:
        adaptType in interface TypeResolver
      • 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: MessageProvider
        Create a message based on the fully qualified message name and field-value mapping.
        Specified by:
        createMessage in interface MessageProvider
      • selectField

        public @Nullable java.lang.Object selectField​(java.lang.Object message,
                                                      java.lang.String fieldName)
        Description copied from interface: MessageProvider
        Select field from message.
        Specified by:
        selectField in interface MessageProvider
      • adapt

        public java.lang.Object adapt​(java.lang.Object message)
        Adapt object to its message value.
        Specified by:
        adapt in interface MessageProvider
      • hasField

        public java.lang.Object hasField​(java.lang.Object message,
                                         java.lang.String fieldName)
        Description copied from interface: MessageProvider
        Check whether a field is set on message.
        Specified by:
        hasField in interface MessageProvider