Class RelEnumTypes

java.lang.Object
org.apache.calcite.rel.externalize.RelEnumTypes

public abstract class RelEnumTypes extends Object
Registry of Enum classes that can be serialized to JSON.

Suppose you want to serialize the value SqlTrimFunction.Flag.LEADING to JSON. First, make sure that SqlTrimFunction.Flag is registered. The type will be serialized as "SYMBOL". The value will be serialized as the string "LEADING".

When we deserialize, we rely on the fact that the registered enum classes have distinct values. Therefore, knowing that (type="SYMBOL", value="LEADING") we can convert the string "LEADING" to the enum Flag.LEADING.

  • Method Details

    • fromEnum

      public static @Nullable Object fromEnum(@Nullable Object value)
      Converts a literal into a value that can be serialized to JSON. In particular, if is an enum, converts it to its name.
    • fromEnum

      public static String fromEnum(Enum enumValue)
      Converts an enum into its name. Throws if the enum's class is not registered.